New-VM

New-VM

Creates a new virtual machine.

構文

Parameter Set: No VHD
New-VM [[-Name] <String> ] [[-MemoryStartupBytes] <Int64]> ] [[-Generation] <Int16]> {1 | 2} ] [-AsJob] [-BootDevice <BootDevice]> ] [-CimSession <Microsoft.Management.Infrastructure.CimSession[]> ] [-ComputerName <String[]> ] [-Credential <System.Management.Automation.PSCredential[]> ] [-NoVHD] [-Path <String> ] [-SwitchName <String> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: Existing VHD
New-VM [[-Name] <String> ] [[-MemoryStartupBytes] <Int64]> ] [[-Generation] <Int16]> {1 | 2} ] -VHDPath <String> [-AsJob] [-BootDevice <BootDevice]> ] [-CimSession <Microsoft.Management.Infrastructure.CimSession[]> ] [-ComputerName <String[]> ] [-Credential <System.Management.Automation.PSCredential[]> ] [-Path <String> ] [-SwitchName <String> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: New VHD
New-VM [[-Name] <String> ] [[-MemoryStartupBytes] <Int64]> ] [[-Generation] <Int16]> {1 | 2} ] -NewVHDPath <String> -NewVHDSizeBytes <UInt64> [-AsJob] [-BootDevice <BootDevice]> ] [-CimSession <Microsoft.Management.Infrastructure.CimSession[]> ] [-ComputerName <String[]> ] [-Credential <System.Management.Automation.PSCredential[]> ] [-Path <String> ] [-SwitchName <String> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

詳細説明

The New-VM cmdlet creates a new virtual machine.

パラメーター

-AsJob

Runs the cmdlet as a background job.

Aliases

none

必須/オプション

false

位置

named

既定値

none

パイプライン入力の受け入れ

false

ワイルドカード文字の受け入れ

false

-BootDevice<BootDevice]>

Specifies the device to use as the boot device for the new virtual machine. Allowed values are CD, Floppy, LegacyNetworkAdapter, IDE, NetworkAdapter, and VHD.

When LegacyNetworkAdapter is specified, this configures the new virtual machine with a network adapter that can be used to perform a PXE boot and install an operating system from a network installation server.

Note: Generation 2 virtual machines do not support Floppy, LegacyNetworkAdapter or IDE. Using these values with a Generation 2 virtual machine will cause an error.

VHD and NetworkAdapter are new to Generation 2 virtual machines. If you specify them on a Generation 1 virtual machine, then they are interpreted to be IDE and LegacyNetworkAdapter, respectively.

Aliases

none

必須/オプション

false

位置

named

既定値

none

パイプライン入力の受け入れ

false

ワイルドカード文字の受け入れ

false

-CimSession<Microsoft.Management.Infrastructure.CimSession[]>

リモート セッションまたはリモート コンピューターでコマンドレットを実行します。コンピューター名またはセッション オブジェクト (New-CimSession コマンドレットや Get-CimSession コマンドレットの出力など) を入力します。既定値は、ローカル コンピューター上の現在のセッションです。

Aliases

none

必須/オプション

false

位置

named

既定値

none

パイプライン入力の受け入れ

false

ワイルドカード文字の受け入れ

false

-ComputerName<String[]>

Specifies one or more Hyper-V hosts on which the virtual machine is to be created. NetBIOS names, IP addresses, and fully qualified domain names are allowable. The default is the local computer. Use localhost or a dot (.) to specify the local computer explicitly.

Aliases

none

必須/オプション

false

位置

named

既定値

none

パイプライン入力の受け入れ

false

ワイルドカード文字の受け入れ

false

-Credential<System.Management.Automation.PSCredential[]>

Specifies one or more user accounts that have permission to perform this action. The default is the current user.

Aliases

none

必須/オプション

false

位置

named

既定値

none

パイプライン入力の受け入れ

false

ワイルドカード文字の受け入れ

false

-Generation<Int16]>

Specifies the generation, as an integer, for the virtual machine. The values that are valid in this version of Windows are 1 and 2.

Aliases

none

必須/オプション

false

位置

3

既定値

none

パイプライン入力の受け入れ

false

ワイルドカード文字の受け入れ

false

-MemoryStartupBytes<Int64]>

Specifies the amount of memory, in bytes, to assign to the virtual machine. The default value is 512 MB.

Aliases

none

必須/オプション

false

位置

2

既定値

none

パイプライン入力の受け入れ

false

ワイルドカード文字の受け入れ

false

-Name<String>

Specifies the name of the new virtual machine. The default name is New virtual machine.

Aliases

VMName

必須/オプション

false

位置

1

既定値

none

パイプライン入力の受け入れ

True (ByValue, ByPropertyName)

ワイルドカード文字の受け入れ

false

-NewVHDPath<String>

Creates a new virtual hard disk with the specified path and connects it to the new virtual machine. Absolute paths are allowed. If only a file name is specified, the virtual hard disk is created in the default path configured for the host.

Aliases

none

必須/オプション

true

位置

named

既定値

none

パイプライン入力の受け入れ

false

ワイルドカード文字の受け入れ

false

-NoVHD

Creates a virtual machine without attaching any virtual hard disks.

Aliases

none

必須/オプション

false

位置

named

既定値

none

パイプライン入力の受け入れ

false

ワイルドカード文字の受け入れ

false

-Path<String>

Specifies the directory to store the files for the new virtual machine.

Aliases

none

必須/オプション

false

位置

named

既定値

none

パイプライン入力の受け入れ

false

ワイルドカード文字の受け入れ

false

-SwitchName<String>

Specifies the friendly name of the virtual switch if you want to connect the new virtual machine to an existing virtual switch to provide connectivity to a network. Hyper-V automatically creates a virtual machine with one virtual network adapter, but connecting it to a virtual switch is optional.

Aliases

none

必須/オプション

false

位置

named

既定値

none

パイプライン入力の受け入れ

false

ワイルドカード文字の受け入れ

false

-VHDPath<String>

Specifies the path to a virtual hard disk file.

Aliases

none

必須/オプション

true

位置

named

既定値

none

パイプライン入力の受け入れ

false

ワイルドカード文字の受け入れ

false

-NewVHDSizeBytes<UInt64>

Specifies the size of the dynamic virtual hard disk that is created and attached to the new virtual machine.

Aliases

none

必須/オプション

true

位置

named

既定値

none

パイプライン入力の受け入れ

false

ワイルドカード文字の受け入れ

false

-Confirm

コマンドレットを実行する前に確認メッセージを表示します。

必須/オプション

false

位置

named

既定値

false

パイプライン入力の受け入れ

false

ワイルドカード文字の受け入れ

false

-WhatIf

コマンドレットが実行された場合に何が起きるのかを示します。コマンドレットは実行されません。

必須/オプション

false

位置

named

既定値

false

パイプライン入力の受け入れ

false

ワイルドカード文字の受け入れ

false

<CommonParameters>

このコマンドレットは共通のパラメーターをサポートしています(-Verbose、-Debug、-ErrorAction、-ErrorVariable、-OutBuffer、および -OutVariable)。詳細については、TechNet の「 「about_CommonParameters」 (https://go.microsoft.com/fwlink/p/?LinkID=113216) を参照してください。

入力

入力型は、コマンドレットにパイプできるオブジェクトの型です。

出力

出力型は、コマンドレットが出力するオブジェクトの型です。

  • Microsoft.HyperV.PowerShell.VirtualMachine

使用例

Example 1

This example creates a new virtual machine named new 1 that has 512 MB of memory.

PS C:\> New-VM –Name "new 1" –MemoryStartupBytes 512MB

Example 2

This example creates a virtual machine named new 2 that has 1 GB of memory and that is connected to a new 40 GB virtual hard disk that uses the VHDX format.

PS C:\> New-VM –Name "new 2" –MemoryStartupBytes 1GB –NewVHDPath d:\vhd\base.vhdx

Example 3

This example creates a virtual machine named new 3 that has 1 GB of memory and connects it to an existing virtual hard disk that uses the VHDX format.

PS C:\> New-VM –Name "new 3" –MemoryStartupBytes 1GB –VHDPath d:\vhd\BaseImage.vhdx