New-VM

New-VM

Creates a new virtual machine.

Syntax

Parameter Set: No VHD
New-VM [[-Name] <String> ] [[-MemoryStartupBytes] <Int64> ] [[-Generation] <Int16> ] [-AsJob] [-BootDevice <BootDevice> {CD | Floppy | LegacyNetworkAdapter | IDE | NetworkAdapter | VHD} ] [-ComputerName <String[]> ] [-NoVHD] [-Path <String> ] [-SwitchName <String> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: Existing VHD
New-VM [[-Name] <String> ] [[-MemoryStartupBytes] <Int64> ] [[-Generation] <Int16> ] -VHDPath <String> [-AsJob] [-BootDevice <BootDevice> {CD | Floppy | LegacyNetworkAdapter | IDE | NetworkAdapter | VHD} ] [-ComputerName <String[]> ] [-Path <String> ] [-SwitchName <String> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: New VHD
New-VM [[-Name] <String> ] [[-MemoryStartupBytes] <Int64> ] [[-Generation] <Int16> ] -NewVHDPath <String> -NewVHDSizeBytes <UInt64> [-AsJob] [-BootDevice <BootDevice> {CD | Floppy | LegacyNetworkAdapter | IDE | NetworkAdapter | VHD} ] [-ComputerName <String[]> ] [-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.

Aliasse

Keiner

Erforderlich?

false

Position?

named

Standardwert

Keiner

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.

Aliasse

Keiner

Erforderlich?

false

Position?

named

Standardwert

Keiner

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.

Aliasse

Keiner

Erforderlich?

false

Position?

named

Standardwert

.

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.

Aliasse

Keiner

Erforderlich?

false

Position?

3

Standardwert

Keiner

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.

Aliasse

Keiner

Erforderlich?

false

Position?

2

Standardwert

Keiner

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

false

-Name<String>

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

Aliasse

VMName

Erforderlich?

false

Position?

1

Standardwert

Keiner

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.

Aliasse

Keiner

Erforderlich?

true

Position?

named

Standardwert

Keiner

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

false

-NoVHD

Creates a virtual machine without attaching any virtual hard disks.

Aliasse

Keiner

Erforderlich?

false

Position?

named

Standardwert

Keiner

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

false

-Path<String>

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

Aliasse

Keiner

Erforderlich?

false

Position?

named

Standardwert

Keiner

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.

Aliasse

Keiner

Erforderlich?

false

Position?

named

Standardwert

Keiner

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

false

-VHDPath<String>

Specifies the path to a virtual hard disk file.

Aliasse

Keiner

Erforderlich?

true

Position?

named

Standardwert

Keiner

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.

Aliasse

Keiner

Erforderlich?

true

Position?

named

Standardwert

Keiner

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

false

-Confirm

Sie werden vor dem Ausführen des Cmdlets zur Bestätigung aufgefordert.

Erforderlich?

false

Position?

named

Standardwert

falsch

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

false

-WhatIf

Zeigt, was geschieht, wenn das Cmdlet ausgeführt wird. Das Cmdlet wird nicht ausgeführt.

Erforderlich?

false

Position?

named

Standardwert

falsch

Pipelineeingaben akzeptieren?

false

Platzhalterzeichen akzeptieren?

false

<CommonParameters>

Dieses Cmdlet unterstützt die allgemeinen Parameter: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, -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 über die Pipeline an das Cmdlet übergeben werden 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