Share via


New-SCVirtualMachine

Applies To: System Center 2012 - Virtual Machine Manager

New-SCVirtualMachine

Creates a virtual machine to be managed by VMM.

Syntax

Parameter Set: NewStoredVmFromHardwareProfile
New-SCVirtualMachine [-Name] <String> -LibraryServer <LibraryServer> -SharePath <String> [-CPUCount <Byte> ] [-CPULimitForMigration <Boolean> ] [-CPULimitFunctionality <Boolean> ] [-CPURelativeWeight <Int32> ] [-CPUType <ProcessorType> ] [-DelayStartSeconds <Int32> ] [-Description <String> ] [-DynamicMemoryBufferPercentage <Int32> ] [-DynamicMemoryEnabled <Boolean> ] [-DynamicMemoryMaximumMB <Int32> ] [-HardwareProfile <HardwareProfile> ] [-JobGroup <Guid> ] [-JobVariable <String> ] [-MemoryMB <Int32> ] [-MemoryWeight <Int32> ] [-MonitorMaximumCount <Int32> ] [-MonitorMaximumResolution <String> ] [-OperatingSystem <OperatingSystem> ] [-Owner <String> ] [-PROTipID <Guid> ] [-ReturnImmediately] [-RunAsynchronously] [-SkipInstallVirtualizationGuestServices] [-StartAction <VMStartAction> ] [-StopAction <VMStopAction> ] [-UseLocalVirtualHardDisk] [-UserRole <UserRole> ] [-VirtualVideoAdapterEnabled <Boolean> ] [-VMMServer <ServerConnection> ] [ <CommonParameters>]

Parameter Set: NewStoredVmFromVirtualDisk
New-SCVirtualMachine [-Name] <String> -LibraryServer <LibraryServer> -SharePath <String> -VirtualHardDisk <StandaloneVirtualHardDisk> [-CPUCount <Byte> ] [-CPULimitForMigration <Boolean> ] [-CPULimitFunctionality <Boolean> ] [-CPURelativeWeight <Int32> ] [-CPUType <ProcessorType> ] [-DelayStartSeconds <Int32> ] [-Description <String> ] [-DynamicMemoryBufferPercentage <Int32> ] [-DynamicMemoryEnabled <Boolean> ] [-DynamicMemoryMaximumMB <Int32> ] [-HardwareProfile <HardwareProfile> ] [-JobGroup <Guid> ] [-JobVariable <String> ] [-MemoryMB <Int32> ] [-MemoryWeight <Int32> ] [-MonitorMaximumCount <Int32> ] [-MonitorMaximumResolution <String> ] [-OperatingSystem <OperatingSystem> ] [-Owner <String> ] [-PROTipID <Guid> ] [-ReturnImmediately] [-RunAsynchronously] [-SkipInstallVirtualizationGuestServices] [-StartAction <VMStartAction> ] [-StopAction <VMStopAction> ] [-UseLocalVirtualHardDisk] [-UserRole <UserRole> ] [-VirtualVideoAdapterEnabled <Boolean> ] [ <CommonParameters>]

Parameter Set: NewStoredVmFromVm
New-SCVirtualMachine [-Name] <String> -LibraryServer <LibraryServer> -SharePath <String> -VM <VM> [-CPUCount <Byte> ] [-CPULimitForMigration <Boolean> ] [-CPULimitFunctionality <Boolean> ] [-CPURelativeWeight <Int32> ] [-CPUType <ProcessorType> ] [-DelayStartSeconds <Int32> ] [-Description <String> ] [-DynamicMemoryBufferPercentage <Int32> ] [-DynamicMemoryEnabled <Boolean> ] [-DynamicMemoryMaximumMB <Int32> ] [-HardwareProfile <HardwareProfile> ] [-JobGroup <Guid> ] [-JobVariable <String> ] [-MemoryMB <Int32> ] [-MemoryWeight <Int32> ] [-MonitorMaximumCount <Int32> ] [-MonitorMaximumResolution <String> ] [-OperatingSystem <OperatingSystem> ] [-Owner <String> ] [-PROTipID <Guid> ] [-ReturnImmediately] [-RunAsynchronously] [-SkipInstallVirtualizationGuestServices] [-StartAction <VMStartAction> ] [-StopAction <VMStopAction> ] [-UseLocalVirtualHardDisk] [-UserRole <UserRole> ] [-VirtualVideoAdapterEnabled <Boolean> ] [ <CommonParameters>]

Parameter Set: NewVmFromComputerTierScaleOut
New-SCVirtualMachine [-Name] <String> -ComputerTier <ComputerTier> [-ComputerName <String> ] [-CPUCount <Byte> ] [-CPULimitForMigration <Boolean> ] [-CPULimitFunctionality <Boolean> ] [-CPURelativeWeight <Int32> ] [-CPUType <ProcessorType> ] [-DelayStartSeconds <Int32> ] [-Description <String> ] [-DynamicMemoryBufferPercentage <Int32> ] [-DynamicMemoryEnabled <Boolean> ] [-DynamicMemoryMaximumMB <Int32> ] [-HardwareProfile <HardwareProfile> ] [-JobGroup <Guid> ] [-JobVariable <String> ] [-MemoryMB <Int32> ] [-MemoryWeight <Int32> ] [-MonitorMaximumCount <Int32> ] [-MonitorMaximumResolution <String> ] [-OperatingSystem <OperatingSystem> ] [-Owner <String> ] [-PROTipID <Guid> ] [-ReturnImmediately] [-RunAsynchronously] [-SkipInstallVirtualizationGuestServices] [-StartAction <VMStartAction> ] [-StopAction <VMStopAction> ] [-UseLocalVirtualHardDisk] [-UserRole <UserRole> ] [-VirtualVideoAdapterEnabled <Boolean> ] [ <CommonParameters>]

Parameter Set: NewVmFromHWProfile
New-SCVirtualMachine [-Name] <String> -Path <String> -VMHost <Host> [-BlockDynamicOptimization <Boolean> ] [-CPUCount <Byte> ] [-CPULimitForMigration <Boolean> ] [-CPULimitFunctionality <Boolean> ] [-CPURelativeWeight <Int32> ] [-CPUType <ProcessorType> ] [-DelayStartSeconds <Int32> ] [-Description <String> ] [-DynamicMemoryBufferPercentage <Int32> ] [-DynamicMemoryEnabled <Boolean> ] [-DynamicMemoryMaximumMB <Int32> ] [-HardwareProfile <HardwareProfile> ] [-HighlyAvailable <Boolean> ] [-JobGroup <Guid> ] [-JobVariable <String> ] [-MemoryMB <Int32> ] [-MemoryWeight <Int32> ] [-MonitorMaximumCount <Int32> ] [-MonitorMaximumResolution <String> ] [-OperatingSystem <OperatingSystem> ] [-Owner <String> ] [-PROTipID <Guid> ] [-ReturnImmediately] [-RunAsynchronously] [-SkipInstallVirtualizationGuestServices] [-StartAction <VMStartAction> ] [-StartVM] [-StopAction <VMStopAction> ] [-UseLocalVirtualHardDisk] [-UserRole <UserRole> ] [-VirtualVideoAdapterEnabled <Boolean> ] [-VMMServer <ServerConnection> ] [ <CommonParameters>]

Parameter Set: NewVmFromTemplate
New-SCVirtualMachine [-Name] <String> -Path <String> -VMHost <Host> -VMTemplate <Template> [-AnswerFile <Script> ] [-BlockDynamicOptimization <Boolean> ] [-ComputerName <String> ] [-CPUCount <Byte> ] [-CPULimitForMigration <Boolean> ] [-CPULimitFunctionality <Boolean> ] [-CPURelativeWeight <Int32> ] [-CPUType <ProcessorType> ] [-DelayStartSeconds <Int32> ] [-Description <String> ] [-Domain <String> ] [-DomainJoinCredential <VMMCredential> ] [-DynamicMemoryBufferPercentage <Int32> ] [-DynamicMemoryEnabled <Boolean> ] [-DynamicMemoryMaximumMB <Int32> ] [-FullName <String> ] [-GuestOSProfile <GuestOSProfile> ] [-GuiRunOnceCommands <String[]> ] [-HardwareProfile <HardwareProfile> ] [-HighlyAvailable <Boolean> ] [-JobGroup <Guid> ] [-JobVariable <String> ] [-LocalAdministratorCredential <VMMCredential> ] [-MemoryMB <Int32> ] [-MemoryWeight <Int32> ] [-MergeAnswerFile <Boolean> ] [-MonitorMaximumCount <Int32> ] [-MonitorMaximumResolution <String> ] [-OperatingSystem <OperatingSystem> ] [-OrganizationName <String> ] [-Owner <String> ] [-ProductKey <String> ] [-PROTipID <Guid> ] [-ReturnImmediately] [-RunAsynchronously] [-SkipInstallVirtualizationGuestServices] [-StartAction <VMStartAction> ] [-StartVM] [-StopAction <VMStopAction> ] [-TimeZone <Int32> ] [-UseLocalVirtualHardDisk] [-UserRole <UserRole> ] [-VirtualVideoAdapterEnabled <Boolean> ] [-Workgroup <String> ] [ <CommonParameters>]

Parameter Set: NewVmFromVirtualDisk
New-SCVirtualMachine [-Name] <String> -Path <String> -VirtualHardDisk <StandaloneVirtualHardDisk> -VMHost <Host> [-BlockDynamicOptimization <Boolean> ] [-CPUCount <Byte> ] [-CPULimitForMigration <Boolean> ] [-CPULimitFunctionality <Boolean> ] [-CPURelativeWeight <Int32> ] [-CPUType <ProcessorType> ] [-DelayStartSeconds <Int32> ] [-Description <String> ] [-DynamicMemoryBufferPercentage <Int32> ] [-DynamicMemoryEnabled <Boolean> ] [-DynamicMemoryMaximumMB <Int32> ] [-HardwareProfile <HardwareProfile> ] [-HighlyAvailable <Boolean> ] [-JobGroup <Guid> ] [-JobVariable <String> ] [-MemoryMB <Int32> ] [-MemoryWeight <Int32> ] [-MonitorMaximumCount <Int32> ] [-MonitorMaximumResolution <String> ] [-OperatingSystem <OperatingSystem> ] [-Owner <String> ] [-PROTipID <Guid> ] [-ReturnImmediately] [-RunAsynchronously] [-SkipInstallVirtualizationGuestServices] [-StartAction <VMStartAction> ] [-StartVM] [-StopAction <VMStopAction> ] [-UseLocalVirtualHardDisk] [-UserRole <UserRole> ] [-VirtualVideoAdapterEnabled <Boolean> ] [ <CommonParameters>]

Parameter Set: NewVmFromVm
New-SCVirtualMachine [-Name] <String> -Path <String> -VM <VM> -VMHost <Host> [-CPUCount <Byte> ] [-CPULimitForMigration <Boolean> ] [-CPULimitFunctionality <Boolean> ] [-CPURelativeWeight <Int32> ] [-CPUType <ProcessorType> ] [-DelayStartSeconds <Int32> ] [-Description <String> ] [-DynamicMemoryBufferPercentage <Int32> ] [-DynamicMemoryEnabled <Boolean> ] [-DynamicMemoryMaximumMB <Int32> ] [-HardwareProfile <HardwareProfile> ] [-JobGroup <Guid> ] [-JobVariable <String> ] [-MemoryMB <Int32> ] [-MemoryWeight <Int32> ] [-MonitorMaximumCount <Int32> ] [-MonitorMaximumResolution <String> ] [-OperatingSystem <OperatingSystem> ] [-Owner <String> ] [-PROTipID <Guid> ] [-ReturnImmediately] [-RunAsynchronously] [-SkipInstallVirtualizationGuestServices] [-StartAction <VMStartAction> ] [-StartVM] [-StopAction <VMStopAction> ] [-UseLocalVirtualHardDisk] [-UserRole <UserRole> ] [-VirtualVideoAdapterEnabled <Boolean> ] [ <CommonParameters>]

Parameter Set: NewVmFromVmCloud
New-SCVirtualMachine [-Name] <String> -Cloud <Cloud> -VM <VM> [-CapabilityProfile <CapabilityProfile> ] [-CPUCount <Byte> ] [-CPULimitForMigration <Boolean> ] [-CPULimitFunctionality <Boolean> ] [-CPURelativeWeight <Int32> ] [-CPUType <ProcessorType> ] [-DelayStartSeconds <Int32> ] [-Description <String> ] [-DynamicMemoryBufferPercentage <Int32> ] [-DynamicMemoryEnabled <Boolean> ] [-DynamicMemoryMaximumMB <Int32> ] [-HardwareProfile <HardwareProfile> ] [-JobGroup <Guid> ] [-JobVariable <String> ] [-MemoryMB <Int32> ] [-MemoryWeight <Int32> ] [-MonitorMaximumCount <Int32> ] [-MonitorMaximumResolution <String> ] [-OperatingSystem <OperatingSystem> ] [-Owner <String> ] [-PROTipID <Guid> ] [-ReturnImmediately] [-RunAsynchronously] [-SelfServiceRole <SelfServiceUserRole> ] [-SkipInstallVirtualizationGuestServices] [-StartAction <VMStartAction> ] [-StartVM] [-StopAction <VMStopAction> ] [-StoreToLibrary] [-UseLocalVirtualHardDisk] [-UserRole <UserRole> ] [-VirtualVideoAdapterEnabled <Boolean> ] [ <CommonParameters>]

Parameter Set: NewVmFromVmConfig
New-SCVirtualMachine [-Name] <String> -VMConfiguration <BaseVMConfiguration> [-AnswerFile <Script> ] [-BlockDynamicOptimization <Boolean> ] [-CapabilityProfile <CapabilityProfile> ] [-Cloud <Cloud> ] [-ComputerName <String> ] [-CPUCount <Byte> ] [-CPULimitForMigration <Boolean> ] [-CPULimitFunctionality <Boolean> ] [-CPURelativeWeight <Int32> ] [-CPUType <ProcessorType> ] [-DelayStartSeconds <Int32> ] [-Description <String> ] [-Domain <String> ] [-DomainJoinCredential <VMMCredential> ] [-DynamicMemoryBufferPercentage <Int32> ] [-DynamicMemoryEnabled <Boolean> ] [-DynamicMemoryMaximumMB <Int32> ] [-FullName <String> ] [-GuestOSProfile <GuestOSProfile> ] [-GuiRunOnceCommands <String[]> ] [-HardwareProfile <HardwareProfile> ] [-JobGroup <Guid> ] [-JobVariable <String> ] [-LocalAdministratorCredential <VMMCredential> ] [-MemoryMB <Int32> ] [-MemoryWeight <Int32> ] [-MergeAnswerFile <Boolean> ] [-MonitorMaximumCount <Int32> ] [-MonitorMaximumResolution <String> ] [-OperatingSystem <OperatingSystem> ] [-OrganizationName <String> ] [-Owner <String> ] [-ProductKey <String> ] [-PROTipID <Guid> ] [-ReturnImmediately] [-RunAsynchronously] [-SelfServiceRole <SelfServiceUserRole> ] [-SkipInstallVirtualizationGuestServices] [-StartAction <VMStartAction> ] [-StartVM] [-StopAction <VMStopAction> ] [-StoreToLibrary] [-TimeZone <Int32> ] [-UseLocalVirtualHardDisk] [-UserRole <UserRole> ] [-VirtualVideoAdapterEnabled <Boolean> ] [-Workgroup <String> ] [ <CommonParameters>]

Parameter Set: NewVmFromVmConfigScaleOut
New-SCVirtualMachine [-Name] <String> -VMConfigurationScaleOut <BaseVMConfiguration> [-CPUCount <Byte> ] [-CPULimitForMigration <Boolean> ] [-CPULimitFunctionality <Boolean> ] [-CPURelativeWeight <Int32> ] [-CPUType <ProcessorType> ] [-DelayStartSeconds <Int32> ] [-Description <String> ] [-DynamicMemoryBufferPercentage <Int32> ] [-DynamicMemoryEnabled <Boolean> ] [-DynamicMemoryMaximumMB <Int32> ] [-HardwareProfile <HardwareProfile> ] [-JobGroup <Guid> ] [-JobVariable <String> ] [-MemoryMB <Int32> ] [-MemoryWeight <Int32> ] [-MonitorMaximumCount <Int32> ] [-MonitorMaximumResolution <String> ] [-OperatingSystem <OperatingSystem> ] [-Owner <String> ] [-PROTipID <Guid> ] [-ReturnImmediately] [-RunAsynchronously] [-SkipInstallVirtualizationGuestServices] [-StartAction <VMStartAction> ] [-StopAction <VMStopAction> ] [-UseLocalVirtualHardDisk] [-UserRole <UserRole> ] [-VirtualVideoAdapterEnabled <Boolean> ] [ <CommonParameters>]

Detailed Description

The New-SCVirtualMachine cmdlet creates a virtual machine to be managed by System Center Virtual Machine Manager (VMM). You can create a virtual machine from an existing stopped virtual machine deployed on a host, from an existing virtual machine stored in the VMM library, from a virtual machine template, from an existing virtual hard disk that already contains an operating system, or from a blank virtual hard disk. For example, you can create a new virtual machine from an existing hard disk that contains a third-party operating system, such as Linux.

When you deploy a new virtual machine to a Hyper-V host, you can specify a location for the virtual machine files, or use the default path of <C>:\ProgramData\Microsoft\Windows\Hyper-V

When you deploy a new virtual machine on a VMware ESX host or Citrix XenServer host, there is no default path to store the virtual machine files, so you must specify the path when you create the virtual machine.

As an alternative to using New-SCVirtualMachine, you can also use the following cmdlets to create a new virtual machine:

- New-SCP2V - creates a new virtual machine from an existing physical

machine (a P2V conversion). For more information, type: "Get-Help

New-SCP2V -detailed".

- New-SCV2V - creates a new virtual machine from an existing virtual

machine, such as a virtual machine created in VMWare (a V2V

conversion). For more information, type: "Get-Help New-SCV2V -detailed".

For more information about New-SCVirtualMachine, type: "Get-Help New-SCVirtualMachine -online".

Parameters

-AnswerFile<Script>

Specifies a script object stored in the VMM library to use as an answer file. The name of the answer file script depends on the operating system that you want to install on a virtual machine:

ANSWER FILE GUEST OS TO INSTALL ON VM

----------- -------------------------

Sysprep.inf Windows XP, Windows Server 2000, or Windows Server 2003

Unattend.xml Windows Vista, Windows 7, or Windows Server 2008

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-BlockDynamicOptimization<Boolean>

Indicates whether dynamic optimization is blocked for a virtual machine.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-CapabilityProfile<CapabilityProfile>

Specifies a capability profile object.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Cloud<Cloud>

Specifies a private cloud object.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ComputerName<String>

Specifies the name of a computer that VMM can uniquely identify on your network. Valid formats are: FQDN, IPv4 or IPv6 address, or NetBIOS name.

NOTE: See the examples for a specific cmdlet to determine how that cmdlet specifies the computer name.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ComputerTier<ComputerTier>

Specifies a computer tier object.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-CPUCount<Byte>

Specifies the number of CPUs on a virtual machine, on a hardware profile, or on a template. See the examples for a specific cmdlet to determine how that cmdlet uses this parameter.

TYPE OF HOST NUMBER OF PROCESSORS

------------ --------------------

Hyper-V Up to 4 CPUs per VM; varies by guest OS

VMware ESX Up to 4 CPUs per VM for any supported guest OS

Exception: 1 CPU on a VM running Windows NT 4.0

Citrix XenServer Up to 8 CPUs per VM; varies by guest OS

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-CPULimitForMigration<Boolean>

Limits, when set to $True, processor features for the specified virtual machine in order to enable migration to a physical computer that has a different version of the same processor as the source computer. VMM does not support migrating virtual machines between physical computers that have processors from different manufacturers.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-CPULimitFunctionality<Boolean>

Enables running an older operating system (such as Windows NT 4.0) on a virtual machine deployed on a Hyper-V host or on a VMware ESX host by providing limited CPU functionality for the virtual machine.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-CPURelativeWeight<Int32>

Specifies the amount of CPU resources on a host that this virtual machine can use relative to other virtual machines on the same host. A virtual machine with a higher setting is allocated more CPU resources than a virtual machine with a lower setting.

TYPE OF HOST RANGE OF RELATIVE VALUES

------------ ------------------------

Hyper-V 1 to 10000

VMware ESX 2000 = High

1500 = Above Normal

1000 = Normal (default)

750 = Below Normal

500 = Low

1 to 1000000 = Custom

The VMware term for these values is "shares."

Citrix XenServer 1 to 65536, normal is 256

NOTE: See the examples for a specific cmdlet to determine how that cmdlet uses this parameter.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-CPUType<ProcessorType>

Specifies the type of CPU for a virtual machine. To retrieve a list of all CPU types that are available for use in virtual machines in a VMM environment, type: "Get-SCCPUType"

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-DelayStartSeconds<Int32>

Specifies the number of seconds to wait after the virtualization service starts before automatically starting a virtual machine. This delay is used to stagger the startup time of multiple virtual machines to help reduce the demand on the physical computer"s resources. A typical setting might be 30 to 60 seconds.

TYPE OF HOST MAXIMUM CONFIGURABLE DELAY

------------ --------------------------------

Hyper-V 1000000000 seconds (277777 hours)

VMware ESX 65535 seconds (18 hours)

Citrix XenServer Does not apply to XenServer virtual machines

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Description<String>

States a description for the specified object.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Domain<String>

Specifies a fully qualified domain name (FQDN) for an Active Directory domain.

Example format: -Domain "Domain01.Corp.Contoso.com"

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-DomainJoinCredential<VMMCredential>

Specifies the user name and password of an account with permission to join a computer to the domain. A limited rights account should be used for joining computers (either physical or virtual) to the domain.

Example format for a PS credential:

$DomainJoinCredential = Get-Credenital

-Domain "ThisDomain.Corp.Contoso.com" -DomainJoinCredential $DomainJoinCredential

Example format for a Run As account:

$DomainJoinCredential = Get-SCRunAsAccount -Name "RunAsAcct01"

-Domain "ThisDomain.Corp.Contoso.com" -DomainJoinCredential $DomainJoinCredential

NOTE: You can use the DomainJoinCredential parameter to specify credentials (on a VMHostProfile) for joining a physical host computer to the domain, or to specify credentials (on a new or existing template, on a new or existing guest operating system profile, or on a new virtual machine) for joining a virtual machine to the domain.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-DynamicMemoryBufferPercentage<Int32>

Specifies the percentage of memory above a virtual machine"s current memory allocation which the host should try to reserve as a buffer. The default value is 20

Example format: -DynamicMemoryTargetBufferPercentage 20

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-DynamicMemoryEnabled<Boolean>

Enables, when set to $True, dynamic memory for virtual machines. You can enable dynamic memory directly on a virtual machine, or on a template or hardware profile that will be used to create virtual machines. The default value is False.

REQUIRED: You can enable dynamic memory for a virtual machine only if that virtual machine is deployed on a host running Windows Server 2008 SP1 or later or if the virtual machine is stored in a library in a stopped state (hardware changes to a stored virtual machine can only be made if the virtual machine does not have snapshots). Enabling dynamic memory on a virtual machine stored in a library will limit placement of that machine to hosts running Windows Server 2008 SP1 or later.

Example format: -DynamicMemoryEnabled $True

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-DynamicMemoryMaximumMB<Int32>

Specifies the maximum amount of memory that can be allocated to a virtual machine if dynamic memory is enabled. The default value is 65536.

REQUIRED: You can enable dynamic memory for a virtual machine only if that virtual machine is deployed on a host running Windows Server 2008 R2 SP1 or later or if the virtual machine is stored in a library in a stopped state (hardware changes to a stored virtual machine can only be made if the virtual machine does not have snapshots). Enabling dynamic memory on a virtual machine stored in a library will limit placement of that machine to hosts running Windows Server 2008 R2 SP1 or later.

Example format: -DynamicMemoryMaximumMB 1024

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-FullName<String>

Specifies the name of the person in whose name a virtual machine is registered.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-GuestOSProfile<GuestOSProfile>

Specifies a guest operating system profile object.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-GuiRunOnceCommands<String[]>

Specifies one or more commands to add to the [GuiRunOnce] section of an unattended answer file (such as Unattend.xml). Use single quotes around each string enclosed in double quotes.

Example format:

-GuiRunOnceCommands '"C:\APF\APFPostSysPrepCopy.cmd PARAMS1"', '"C:\APF\APFPostSysPrepCopy.cmd PARAMS1"'

For information about how Windows PowerShell uses quotes, type: "Get-Help about_Quoting_Rules"

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-HardwareProfile<HardwareProfile>

Specifies a hardware profile object.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-HighlyAvailable<Boolean>

Specifies that a virtual machine will be placed on a Hyper-V host that is part of a host cluster. Configure this setting on a virtual machine, or on a template or hardware profile that will be used to create virtual machines.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-JobGroup<Guid>

Specifies an identifier for a series of commands that will run as a set just before the final command that includes the same job group identifier runs.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-JobVariable<String>

Specifies that job progress is tracked and stored in the variable named by this parameter.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-LibraryServer<LibraryServer>

Specifies a VMM library server object.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-LocalAdministratorCredential<VMMCredential>

Specifies the user name and password for the local Administrator account. Specifying credentials on a new or existing template, on a new or existing guest operating system profile, or on a new virtual machine overrides any existing Administrator password.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-MemoryMB<Int32>

Specifies, in megabytes (MB), the amount of random access memory (RAM) on the host that is allocated to a virtual machine. The default value is 512 MB. For a virtual machine on which dynamic memory is enabled (on a host running Windows Server 2008 R2 SP1 or later), use MemoryMB to specify the startup memory value.

TYPE OF HOST MAXIMUM HOST MEMORY ASSIGNABLE TO VM

------------ ------------------------------------

Hyper-V Up to 65536 MB RAM per virtual machine

VMware ESX Server 3.0.x Up to 16384 MB RAM per virtual machine

VMware ESX Server 3.5.x Up to 65532 MB RAM per virtual machine

Citrix XenServer Up to 32265 MB RAM per VM

Example format: -MemoryMB 1024

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-MemoryWeight<Int32>

Indicates the priority in allocating memory to a virtual machine, relative to other virtual machines on the same host. A virtual machine with a higher setting is allocated more memory resources than a virtual machine with a lower setting.

For a host running Windows Server 2008 R2 SP1 or later, 5000 = Normal, 10000 = High, 0 = Low, 1 to 10000 = Custom.

NOTE: See the examples for a specific cmdlet to determine how that cmdlet uses this parameter.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-MergeAnswerFile<Boolean>

Specifies that the cmdlet merge the specified answer file with the specified guest operating system settings. The default value is TRUE. This parameter is used by the VMM console. You do not need to use this parameter at the command prompt.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-MonitorMaximumCount<Int32>

Specifies the maximum number of monitors supported by a virtual video adapter.

Example format: -MonitorMaximumCount 3

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-MonitorMaximumResolution<String>

Specifies, as a string, the value that represents the maximum possible monitor resolution of a virtual video adapter. Valid values are: "1024x768", "1280x1024", "1600x1200", "1920x1200". Default value: "1280x1024"

Example format: -MonitorResolutionMaximum "1600x1200"

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Name<String>

Specifies the name of a VMM object.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-OperatingSystem<OperatingSystem>

Specifies the type of operating system for a virtual machine. To list the names of all available operating systems in VMM, type: "Get-SCOperatingSystem".

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-OrganizationName<String>

Specifies the name of the organization for the person in whose name a virtual machine is registered.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Owner<String>

Specifies the owner of a VMM object in the form of a valid domain user account.

Example format: -Owner "Contoso\ReneeLo"

Example format: -Owner "ReneeLo@Contoso"

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Path<String>

Specifies the destination path for the operation.

Example formats:

Local path -Path "F:\"

UNC path -Path "\\Library\Templates"

Volume GUID path -Path "\\?\Volume{4703c1ea-8ae7-11db-b473-00123f7603e3}\"

VMware ESX path "Path "[storage1]\MyVMwareFolderForVMs\MyVM.vmx"

Citrix XenServer path - Path "Local storage[99b6212f-b63d-c676-25f9-d6c460992de7]"

Wildcards are supported for "Get" cmdlets and when you specify the UNC path:

Example format:

UNC path -Path "\\VMHostServer\MyVMs\*VM*"

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ProductKey<String>

Specifies a product key. The product key is a 25-digit number that identifies the product license. A product key can be used to register VMM or an operating system to be installed on a virtual machine or host.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-PROTipID<Guid>

Specifies the ID of the PRO tip that triggered this action. This allows for auditing of PRO tips.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ReturnImmediately

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-RunAsynchronously

Indicates that the job runs asynchronously so that control returns to the command shell immediately.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-SelfServiceRole<SelfServiceUserRole>

Specifies the self-service role with permission to access the virtual machine.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-SharePath<String>

Specifies a path to a valid library share on an existing library server that uses a Universal Naming Convention (UNC) path.

Example format: "SharePath "\\LibServer01\LibShare"

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-SkipInstallVirtualizationGuestServices

Skips the installation of virtualization guest services on a virtual machine. By default, this parameter is set to $False and VMM installs the appropriate virtualization guest service automatically. For a virtual machine on a Hyper-V host, the virtualization guest service is called Integration Components (VMGuest.iso). For a virtual machine on a XenServer host, the virtualization guest service is called Citrix Tools for Virtual Machines (xs-tools.iso). Virtual machines on a VMware ESX host do not use a virtualization guest service.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-StartAction<VMStartAction>

Specifies the behavior of a virtual machine when the virtualization service (Hyper-V, VMware, or XenServer) starts. Valid values are: AlwaysAutoTurnOnVM, NeverAutoTurnOnVM, TurnOnVMIfRunningWhenVSStopped.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-StartVM

Specifies that the virtual machine starts when it arrives at the destination host.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-StopAction<VMStopAction>

Specifies the behavior of the virtual machine when the virtualization service (Hyper-V, VMware, or XenServer) stops. Valid values are: SaveVM, TurnOffVM, ShutdownGuestOS.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-StoreToLibrary

Indicates that the virtual machine should be stored in the VMM library.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-TimeZone<Int32>

Specifies a number (an index) that identifies a geographical region that shares the same standard time. For a list of time zone indexes, see "Microsoft Time Zone Index Values" at: https://go.microsoft.com/fwlink/?LinkId=120935. If no time zone is specified, the default time zone used for a virtual machine is the same time zone setting that is on the virtual machine host.

Example format to specify the GMT Standard Time zone: -TimeZone 085

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-UseLocalVirtualHardDisk

Verifies that the VHD file (or files) to be used to create the virtual machine exist and are stored on the destination host.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-UserRole<UserRole>

Specifies a user role object.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-VirtualHardDisk<StandaloneVirtualHardDisk>

Specifies a virtual hard disk object.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-VirtualVideoAdapterEnabled<Boolean>

Enables, when set to $True, the Microsoft Synthetic 3D Virtual Video Adapter for virtual machines. You can enable the Virtual Video Adapter directly on a virtual machine, or on a template or hardware profile that will be used to create virtual machines.

REQUIRED: You can enable the Microsoft Synthetic 3D Virtual Video Adapter for a virtual machine only if that virtual machine is deployed on a host running Windows Server 2008 R2 SP1 (with the Remote Desktop Services role and Remote Desktop Virtual Graphics role service installed) or later or if the virtual machine is stored in a library in a stopped state (hardware changes to a stored virtual machine can only be made if the virtual machine does not have snapshots). Enabling the Microsoft Synthetic 3D Virtual Video Adapter on a virtual machine stored in a library will limit placement of that machine to hosts running Windows Server 2008 R2 SP1 (with the Remote Desktop Services role and Remote Desktop Virtual Graphics role service installed) or later.

Example format: -VirtualVideoAdapterEnabled $TRUE

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-VM<VM>

Specifies a virtual machine object.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-VMConfiguration<BaseVMConfiguration>

Specifies a virtual machine configuration object.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-VMConfigurationScaleOut<BaseVMConfiguration>

Specifies a virtual machine configuration object used when scaling out a service.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-VMHost<Host>

Specifies a virtual machine host object. VMM supports Hyper-V hosts, VMware ESX hosts, and Citrix XenServer hosts.

For more information about each type of host, type: "Get-Help Add-SCVMHost -detailed". See the examples for a specific cmdlet to determine how that cmdlet uses this parameter.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-VMMServer<ServerConnection>

Specifies a VMM server object.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-VMTemplate<Template>

Specifies a VMM template object used to create virtual machines.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-Workgroup<String>

Specifies on a new or existing template, on a new or existing guest operating system profile, or on a new virtual machine the name of the workgroup to which you want to join a virtual machine. You can use this parameter to override the existing value on a template or on a guest operating system profile.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • VirtualMachine

Notes

  • Requires a VMM virtual hard disk object, virtual machine template object, or virtual machine object, which can be retrieved by using the Get-SCVirtualHardDisk, Get-SCVMTemplate, or Get-SCVirtualMachine cmdlets, respectively.

Examples

1: Create a virtual machine from a virtual hard disk and deploy it on a host.

The first command gets the virtual hard disk object named "Blank Disk - Large" from the VMM library and stores the object in the $VHD variable.

The second command gets the host object named VMHost01 and stores the object in the $VMHost object.

The last command creates a virtual machine named VM01 from the virtual hard disk stored in $VHD (in this case, "Blank Disk - Large") and deploys the new virtual machine in C:\VirtualMachinePath on VMHost01. The RunAsynchronously parameter returns control to the shell immediately, before the command completes.

PS C:\> $VHD = Get-SCVirtualHardDisk -Name "Blank Disk - Large"
PS C:\> $VMHost = Get-SCVMHost -ComputerName "VMHost01.Contoso.com"
PS C:\> New-SCVirtualMachine -Name "VM01" -VirtualHardDisk $VHD -VMHost $VMHost -Path "C:\VirtualMachinePath" "RunAsynchronously

2: Create a virtual machine from a virtual machine template and deploy it on a host.

The first command gets the virtual machine template object named "WindowsServer2008R2" and stores the object in the $Template variable.

The second command gets the host object named VMHost02 and stores the object in the $VMHost variable.

The last command creates a new virtual machine from the virtual machine template stored in $Template, names the virtual machine VM02, and deploys the virtual machine on host VMHost02, storing its files at C:\VirtualMachinePath. When the virtual machine is created, the following properties are customized: the computer name for the virtual machine (Server01), the name of the person to whom the virtual machine is registered (Renee Lo), the organization name (Contoso), and the product key (substitute your product key for the Xs). Using the RunAsynchronously parameter returns control to the shell immediately, before the job completes.

PS C:\> $VMTemplate = Get-SCVMTemplate -VMMServer "VMMServer01.Contoso.com" | where {$_.Name -eq "WindowsServer2008R2"}
PS C:\> $VMHost = Get-SCVMHost -ComputerName "VMHost02.Contoso.com"
PS C:\> New-SCVirtualMachine -VMTemplate $VMTemplate -Name "VM02" -VMHost $VMHost -Path "C:\VirtualMachinePath" -RunAsynchronously -ComputerName "Server01" -FullName "Renee Lo" -OrgName "Contoso" -ProductKey "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX"

3: Create a virtual machine by cloning an existing virtual machine.

The first command gets the virtual machine object named VM03 and stores the object in the $VM variable.

The second command gets the host object named VMHost03 and stores the object in the $VMHost variable.

The last command checks whether virtual machine VM01 is in a powered off state. If the virtual machine is powered off, the command creates a virtual machine named VM03 from VM01 and deploys the new virtual machine on VMHost03 in C:\VirtualMachinePath. The RunAsynchronously parameter returns control to the shell immediately, before the command completes.

PS C:\> $VM = Get-SCVirtualMachine -Name "VM01"
PS C:\> $VMHost = Get-SCVMHost -ComputerName "VMHost01.Contoso.com"
PS C:\> if($VM.Status -eq "PowerOff"){New-SCVirtualMachine -Name "VM03" -VM $VM -VMHost $VMHost -Path "C:\VirtualMachinePath" "RunAsynchronously}

4. Create a virtual machine from a virtual machine stored in the library.

The first command gets the host object named VMHost04 and stores the object in the $VMHost variable.

The second command gets the virtual machine object named StoredVM01, which is located at the specified path on library server LibServer01, and stores the virtual machine object in the $VM variable.

The last command creates a new virtual machine named VM04 from StoredVM01, provides the new virtual machine with 1024 MB of memory, and deploys it at the specified path. The command also provides a description and owner, and specifies that the start action for the virtual machine is set to never turn on automatically and that the stop action is to save the virrual machine. Using the RunAsynchronously parameter returns control to the shell immediately, before the command completes.

PS C:\> $VMHost = Get-SCVMHost -ComputerName "VMHost04"
PS C:\> $VM = Get-SCVirtualMachine -Name "StoredVM01" | where {$_.LibraryServer.Name -eq "LibServer01.Contoso.com"} | where {$_.Location -eq "\\LibServer01.Consoso.com\MSSCVMMLibrary\StoredVM01"}
PS C:\> New-SCVirtualMachine -VM $VM -Name "VM04" -Description "New VM from VM stored in Library" -Owner "Contoso\ReneeLo" -VMHost $VMHost -Path "C:\VirtualMachinePath" -RunAsynchronously -StartAction NeverAutoTurnOnVM -StopAction SaveVM -MemoryMB 1024

5. Create a highly available virtual machine.

The first command creates a new GUID string and stores it in $VMGuid. This GUID is a job group ID that functions as an identifier that groups subsequent commands that include this identifier into a single job group.

The second command stores the string "HAVM01" in $VMName, and is used to name the new virtual machine.

The third command creates a virtual network adapter with a dynamic MAC address and with VLAN disabled. Because the command uses the JobGroup variable, the network adapter is not created until just before the New-SCVirtualMachine cmdlet in the last command runs.

The fourth command creates an IDE virtual DVD drive connected to the second channel and the first slot. Because the command uses the JobGroup variable, the virtual DVD drive is not created until just before the New-SCVirtualMachine cmdlet in the last command runs.

The fifth command creates a hardware profile and specifies values for the profile name, owner, CPU count, memory, and bootorder. The command disables NumLock as well as limited CPU functionality, which is not needed because this is virtual machine will not have an older operating system, and designates that the virtual machine created by using this hardware profile will be highly available. Because the command uses the JobGroup variable, the hardware profile is not created until just before the New-SCVirtualMachine cmdlet in the last command runs.

The sixth command creates an IDE virtual disk drive with a storage capacity of 4 GB on the first channel and first slot. Because the command uses the JobGroup variable, the new virtual disk drive is not created until just before the New-SCVirtualMachine cmdlet in the last command runs.

The seventh command gets a virtual machine host object by name (VMMHANode02) and stores the object in $VMHost. This host is one node of a host cluster that is managed by VMM.

The eighth command gets the hardware profile object named HWProfile02, which was created in the fifth command, and stores the object in the $HardwareProfile variable.

The ninth command gets an operating system object by name and stores the object in $OperatingSystem.

The last command uses the New-SCVirtualMachine cmdlet and the JobGroup parameter to create a new highly available virtual machine named HAVM01 by using the objects created and obtained in the preceding commands. The command also uses the Path parameter to specify the location where the virtual machine is stored, which must be a cluster-migratable LUN. Additionally, the command specifies that the virtual machine is not started automatically when the host starts and that the virtual machine is put into a saved state when the virtualization service stops. Using the RunAsynchronously parameter returns control to the command shell immediately, before the command completes.

PS C:\> $JobGuid = [System.Guid]::NewGuid().ToString()
PS C:\> $VMName = "HAVM01"
PS C:\> New-SCVirtualNetworkAdapter -JobGroup $JobGuid -PhysicalAddressType Dynamic -VLANEnabled $False
PS C:\> New-SCVirtualDVDDrive -JobGroup $JobGuid -Bus 1 -LUN 0
PS C:\> New-SCHardwareProfile -Owner "Contoso\ReneeLo" -Name "HWProfile02" -CPUCount 1 -MemoryMB 512 -HighlyAvailable $True -NumLock $False -BootOrder "CD", "IdeHardDrive", "PxeBoot", "Floppy" -LimitCPUFunctionality $False -JobGroup $JobGuid
PS C:\> New-SCVirtualDiskDrive -IDE -Bus 0 -LUN 0 -JobGroup $JobGuid -Size 40960 -Dynamic -Filename "HAVM01_disk_1.vhd"
PS C:\> $VMHost = Get-SCVMHost | where {$_.Name -eq "VMMHANode02.Contoso.com"}
PS C:\> $HardwareProfile = Get-SCHardwareProfile | where {$_.Name -eq "HWProfile02"}
PS C:\> $OperatingSystem = Get-SCOperatingSystem | where {$_.Name -eq "64-bit edition of Windows Server 2008 R2 Datacenter"}
PS C:\> New-SCVirtualMachine -Name $VMName -Description "" -VMMServer "VMMServer01.Contoso.com" -Owner "Contoso\ReneeLo" -VMHost $VMHost -Path "R:\" -HardwareProfile $HardwareProfile -JobGroup $JobGuid -OperatingSystem $OperatingSystem -RunAsynchronously -StartAction NeverAutoTurnOnVM -StopAction SaveVM

6: Use an existing VHD file on the destination host to create a new virtual machine from a template.

The first command generates a globally unique identifier (GUID) and stores the GUID string in the $JobGroupID variable. The job group ID functions as an identifier that groups subsequent commands that include this identifier into a single job group.

The second command gets the virtual machine template object named VMTemplate01 and stores the object in the $Template variable. VMTemplate01 is assumed to have a virtual disk drive on IDE Bus 0 LUN 0 that contains a virtual hard disk.

The third command gets the host object named VMHost06 and stores the object in the $VMHost variable.

The fourth command connects the specified virtual hard disk, stored on the physical host at L:\OS.VHD, to the first slot (0) of the primary channel (0) on the virtual IDE controller on the virtual machine instead of the default virtual hard disk in the template. The virtual hard disk stored at L:\OS.VHD contains the operating system that will start on the virtual machine. Additionally, this command uses the JobGroup parameter to specify that it will not run until the New-SCVirtualMachine cmdlet triggers the commands in the JobGroup list to run.

The last command triggers all commands that contain the $JobGroupID variable to run and creates the new virtual machine named VM06 from the template stored in $VMTemplate. The virtual machine is deployed on the host specified in $VMHost and the virtual machine is stored in the root directory of the L: drive. The UseLocalVirtualHarddisk parameter specifies that New-SCVirtualMachine use an existing hard disk on the host instead of copying a vhd from the library. Therefore, the virtual hard disk associated with the virtual disk drive on the template is replaced with the virtual hard drive that exists on the host, L:\OS.VHD. As a result, both the virtual machine and its operating system are stored on the L: drive on the host.

The next example stores the virtual machine and its operating system on different drives.

PS C:\> $JobGroupID = [Guid]::NewGuid().ToString()
PS C:\> $VMTemplate = Get-SCVMTemplate | where {$_.Name -eq "VMTemplate01"}
PS C:\> $VMHost = Get-SCVMHost -ComputerName "VMHost06.Contoso.com"
PS C:\> Move-SCVirtualHardDisk -IDE -BUS 0 -LUN 0 -Path "L:\OS.VHD" -JobGroup $JobGroupID
PS C:\> New-SCVirtualMachine -Name "VM06" -Path "L:\" -VMTemplate $VMTemplate -VMHost $VMHost -JobGroup $JobGroupID -UseLocalVirtualHardDisk

7: Use an existing VHD on the destination host to create a virtual machine from a template, and move another VHD to the new virtual machine.

The first three commands are identical to the first three commands in the previous example. VMTemplate01 is assumed to have a virtual disk drive on IDE Bus 0 and LUN 0 that contains a virtual hard disk.

The fourth command gets the virtual hard disk object named Other.VHD. The Get-SCVirtual HardDisk cmdlet can retrieve virtual hard disk objects from a virtual machine, from a template, or from a standalone file stored in the VMM library. Specifying the -All parameter retrieves a full list of all the subordinate objects independent of the parent object. In this case, the command retrieves all the available virtual hard disk objects and then selects Other.VHD.

The fifth command connects the specified virtual hard disk, stored on the physical host at L:\OS.VHD, to the first slot (0) of the primary channel (0) on the virtual IDE controller on the virtual machine instead of the default virtual hard disk in the template. The virtual hard disk stored at L:\OS.VHD contains the operating system that will start on the virtual machine. Additionally, this command uses the JobGroup parameter to specify that it will not run until the New-SCVirtualMachine cmdlet triggers the commands in the JobGroup list to run.

The sixth command creates a new virtual disk drive object and attaches the virtual hard disk object stored in $VHD to IDE Bus 0 and LUN 1 on the new drive. The command uses the Path parameter to store the virtual hard disk object in $VHD in the root directory of the R drive on the virtual machine, and it specifies that its name is Other.VHD. Additionally, this command uses the JobGroup parameter to specify that it will not run until the last command triggers the commands in the JobGroup list to run.

The last command triggers all commands that contain the $JobGroupID variable to run and creates the new virtual machine named VM07 from the template stored in $VMTemplate. The virtual machine is deployed on the host specified in $VMHost and the virtual machine is stored in the D:\VirtualMachinePath folder. The UseLocalVirtualHarddisk parameter specifies that New-SCVirtualMachine use an existing hard disk on the host instead of copying a vhd from the library.Therefore, the virtual hard disk associated with the virtual disk drive on the template is replaced with the virtual hard drive that exists on the host, L:\OS.VHD. As a result, the path to the virtual machine is D:\VirtualMachinePath\VM07, the path to the operating system is L:\OS.VHD, and the path to the other virtual hard disk is R:\Other.VHD.

PS C:\> $JobGroupID = [guid]::NewGuid()
PS C:\> $VMTemplate = Get-SCVMTemplate | where {$_.Name -eq "VMTemplate01"}
PS C:\> $VMHost = Get-SCVMHost -ComputerName "VMHost07.Contoso.com"
PS C:\> $VHD = Get-SCVirtualHardDisk -All | where {$_.Name -eq "Other.Vhd"}
PS C:\> Move-SCVirtualHardDisk -IDE -BUS 0 -LUN 0 -Path "L:\OS.VHD" -JobGroup $JobGroupID
PS C:\> New-SCVirtualDiskDrive -VirtualHardDisk $VHD -IDE -BUS 0 -LUN 1 -Path "R:\" -Filename "Other.Vhd" -JobGroup $JobGroupID
PS C:\> New-SCVirtualMachine -Name "VM07" -Path "D:\VirtualMachinePath" -VMTemplate $VMTemplate -VMHost $VMHost -JobGroup $JobGroupID -UseLocalVirtualHardDisk

Get-SCVirtualMachine

Move-SCVirtualMachine

New-SCP2V

New-SCV2V

Read-SCVirtualMachine

Remove-SCVirtualMachine

Repair-SCVirtualMachine

Resume-SCVirtualMachine

Save-SCVirtualMachine

Set-SCVirtualMachine

Start-SCVirtualMachine

Stop-SCVirtualMachine

Suspend-SCVirtualMachine