New-VM

New-VM

Creates a new virtual machine.

Syntax

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>]

Detaillierte Beschreibung

The New-VM cmdlet creates a new virtual machine.

Parameter

-AsJob

Runs the cmdlet as a background job.

Aliase

none

Erforderlich?

false

Position?

named

Standardwert

none

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

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.

Aliase

none

Erforderlich?

false

Position?

named

Standardwert

none

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

false

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

Das Cmdlet wird in einer Remotesitzung oder auf einem Remotecomputer ausgeführt. Geben Sie einen Computernamen oder ein Sitzungsobjekt ein, wie z. B. die Ausgabe eines New-CimSession oder Get-CimSession-Cmdlets. Der Standardwert ist die aktuelle Sitzung auf dem lokalen Computer.

Aliase

none

Erforderlich?

false

Position?

named

Standardwert

none

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

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.

Aliase

none

Erforderlich?

false

Position?

named

Standardwert

none

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

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.

Aliase

none

Erforderlich?

false

Position?

named

Standardwert

none

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

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.

Aliase

none

Erforderlich?

false

Position?

3

Standardwert

none

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

false

-MemoryStartupBytes<Int64]>

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

Aliase

none

Erforderlich?

false

Position?

2

Standardwert

none

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

false

-Name<String>

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

Aliase

VMName

Erforderlich?

false

Position?

1

Standardwert

none

Pipelineeingaben akzeptieren?

True (ByValue, ByPropertyName)

Platzhalterzeichen akzeptieren?

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.

Aliase

none

Erforderlich?

true

Position?

named

Standardwert

none

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

false

-NoVHD

Creates a virtual machine without attaching any virtual hard disks.

Aliase

none

Erforderlich?

false

Position?

named

Standardwert

none

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

false

-Path<String>

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

Aliase

none

Erforderlich?

false

Position?

named

Standardwert

none

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

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.

Aliase

none

Erforderlich?

false

Position?

named

Standardwert

none

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

false

-VHDPath<String>

Specifies the path to a virtual hard disk file.

Aliase

none

Erforderlich?

true

Position?

named

Standardwert

none

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

false

-NewVHDSizeBytes<UInt64>

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

Aliase

none

Erforderlich?

true

Position?

named

Standardwert

none

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

false

-Confirm

Fordert Sie vor der Ausführung des Cmdlet zum Bestätigen auf.

Erforderlich?

false

Position?

named

Standardwert

false

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

false

-WhatIf

Zeit, was passieren würde, wenn das Cmdlet ausgeführt wird. Das Cmdlet wird nicht ausgeführt.

Erforderlich?

false

Position?

named

Standardwert

false

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

false

<CommonParameters>

Dieses Cmdlet unterstützt die allgemeinen Parameter: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer und -OutVariable. Weitere Informationen finden Sie unter about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Eingaben

Der Eingabetyp ist der Typ der Objekte, die Sie per Piping an das Cmdlet übergeben können.

Ausgaben

Der Ausgabetyp ist der Typ der Objekte, die vom Cmdlet ausgegeben werden.

  • Microsoft.HyperV.PowerShell.VirtualMachine

Beispiele

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