This example creates a virtual machine named VM01 that has 1 GB of memory and that is connected to
a new 40 GB virtual hard disk that uses the VHDX format.
This example creates a virtual machine named VM01. The machine has the same generation and amount
of assigned memory as the existing machine named PreviousVM and connects to the same network
switch.
Parameters
-AsJob
Runs the cmdlet as a background job.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-BootDevice
Specifies the device to use as the boot device for the new virtual machine. Acceptable values are:
CD
Floppy
LegacyNetworkAdapter
IDE
NetworkAdapter
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 a 32-bit operating system from a network
installation server.
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.
Runs the cmdlet in a remote session or on a remote computer. Enter a computer name or a session
object, such as the output of a New-CimSession or
Get-CimSession cmdlet. The default is the
current session on the local computer.
Parameter properties
Type:
CimSession[]
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-ComputerName
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.
Parameter properties
Type:
String[]
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Aliases:
cf
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Credential
Specifies one or more user accounts that have permission to perform this action. The default is the
current user.
Parameter properties
Type:
PSCredential[]
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Experimental
Specific prerelease VM version 255.0. This parameter is used to experiment with new VM
functionality, but this is not supported and may fail across updates. This VM version is not
supported in release host builds, meaning you can only use this on pre-release host builds (Windows
Insider program).
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Force
Forces the command to run without asking for user confirmation.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Generation
Specifies the generation, as an integer, for the virtual machine. Acceptable values are:
1
2
Parameter properties
Type:
Int16
Default value:
None
Accepted values:
1, 2
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
2
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-GuestStateIsolationType
Specifies the level of isolation for the virtual machine being created. Acceptable values are:
TrustedLaunch: Enables guest state isolation and Trusted Launch security features for the
virtual machine.
VBS: Enables Virtualization Based Security (VBS) isolation for the virtual machine.
SNP: Enables AMD Secure Encrypted Virtualization-Secure Nested Paging (SEV-SNP) isolation for
the virtual machine.
TDX: Enables Intel Trust Domain Extensions (TDX) isolation for the virtual machine.
Disabled: Disables all guest state isolation features for the virtual machine.
Parameter properties
Type:
GuestIsolationType
Default value:
None
Accepted values:
TrustedLaunch, VBS, SNP, TDX, Disabled
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-MemoryStartupBytes
Specifies the amount of memory, in bytes, to assign to the virtual machine. The default value is
512 MB.
Parameter properties
Type:
Int64
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
1
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Name
Specifies the name of the new virtual machine. The default name is New virtual machine.
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
False
DontShow:
False
Aliases:
VMName
Parameter sets
(All)
Position:
0
Mandatory:
False
Value from pipeline:
True
Value from pipeline by property name:
True
Value from remaining arguments:
False
-NewVHDPath
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.
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
New VHD
Position:
Named
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-NewVHDSizeBytes
Specifies the size of the dynamic virtual hard disk that is created and attached to the new virtual
machine.
Parameter properties
Type:
UInt64
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
New VHD
Position:
Named
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-NoVHD
Creates a virtual machine without attaching any virtual hard disks.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
No VHD
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Path
Specifies the directory to store the files for the new virtual machine.
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Prerelease
Specific prerelease VM version 254.0. This parameter is used to experiment with new VM
functionality, but this is not supported and may fail across updates. This VM version is not
supported in release host builds, meaning you can only use this on pre-release host builds (Windows
Insider program).
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-SourceGuestStatePath
Specifies the path to the guest state file for the virtual machine being created. Specifying the
guest state path allows for creation of a new virtual machine that has the same configuration and
state as the existing virtual machine.
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-SwitchName
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.
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Version
Specifies the version during the VM creation process. See,
Get-VMHostSupportedVersion for supported
VM versions on a given host.
Parameter properties
Type:
Version
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-VHDPath
Specifies the path to a virtual hard disk file.
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
Existing VHD
Position:
Named
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Aliases:
wi
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters.