What's New in VMM 2008 R2 Scripting
Applies To: Virtual Machine Manager 2008 R2, Virtual Machine Manager 2008 R2 SP1
The Hyper-V role in Windows Server 2008 R2 includes significant feature improvements. System Center Virtual Machine Manager (VMM) 2008 R2 leverages these new enhancements by adding two new cmdlets and several parameters that extend the functionality of the existing VMM cmdlets.
New and Updated Cmdlets and Parameters in VMM 2008 R2
The following list summarizes the new and updated cmdlets and parameters in VMM 2008 R2.
This cmdlet places a VMM host into maintenance mode. For more information, see Maintenance Mode for Hosts.
This new cmdlet removes a VMM host from maintenance mode and returns it to service. For more information, see Maintenance Mode for Hosts.
You can use the AllowUnencryptedTransfers parameter to specify that network file transfers into or out of a library, or into, out of, or within a host group, do not require encryption. Allowing unencrypted file transfers can improve performance when neither the source computer nor the destination computer requires encryption. This parameter can be used with the Set-LibraryServer and Set-VMHostGroup cmdlets.
You can use the BlockLMIfHostBusy parameter of the Move-VM cmdlet to stop Hyper-V live migration from attempting to restart a live migration that could not previously start because the source host or the destination host was already performing a live migration.
The LimitCPUForMigration parameter limits the processor features for a virtual machine so that the virtual machine can be migrated to a different physical computer that has a different version of the same processor as the source computer. Migrating virtual machines between physical computers with processors from different manufacturers is not supported. This parameter can be used with the following cmdlets: New-HardwareProfile, Set-HardwareProfile, New-VM, Set-VM, and Set-Template.
When you place a host that is a member of a host cluster into maintenance mode using the Disable-VMHost cmdlet, and you use the MoveWithinCluster parameter, all the virtual machines that are currently deployed on the host will be migrated to another host in the same host cluster.
You can use the RemoveLibraryStoreSharePath parameter of the Set-VMMUserRole cmdlet to clear the path to the specified library share. This share is used by members of a self-service user role to store virtual machines or as a repository from which to deploy stored virtual machines or stored ISO images.
When you use the RetainDeletedObjects parameter with the Get-VMMServer cmdlet, the objects in the cache that are marked for deletion will be preserved. This parameter is included for users who might develop a user interface.
When you use the RetainObjectCache parameter with the Get-VMMServer cmdlet, the objects in the cache remain in memory and are not reclaimed by garbage collection. This parameter is included for users who might develop a user interface.
The UseCluster parameter lets you force the transfer of a virtual machine using Windows Server 2008 Cluster Migration, even when Hyper-V live migration is available, when you move a virtual machine using the Move-VM cmdlet. For more information, see Live Migration.
The UseLocalVirtualHardDisks parameter specifies that the virtual hard disk file (.vhd) for a new virtual machine that is created by using the New-VM cmdlet is at a specified location on the destination host, and that no .vhd files will be copied from the library. For more information, see Rapid Provisioning of Virtual Machines.
The VMNetworkOptimizationEnabled parameter enables virtual machine network optimization detection. This feature improves network performance for virtual machines with network adapters that support virtual machine queue (VMQ) or TCP Chimney Offload. VMQ enables creation of a unique network queue for each network adapter. TCP Chimney Offload enables network traffic processing to be offloaded from the networking stack. This parameter can be used with the New-VirtualNetworkAdapter, Set-VirtualNetworkAdapter, New-P2V, and New-V2V cmdlets.
You can use the VMWarePortGroup parameter to specify a VMware port group.
Hyper-V live migration allows you to migrate a running virtual machine from one node of a Windows Server 2008 R2 failover cluster to another node in the same cluster without any perceived downtime for users. When you use the Move-VM cmdlet to move a running virtual machine that is on a clustered Windows Server 2008 R2 host, VMM will attempt to move the virtual machine using Hyper-V live migration. If Hyper-V live migration is not available, VMM will attempt to use Cluster Migration to move the virtual machine. To force VMM to use Windows Server 2008 Cluster Migration even if Hyper-V live migration is available, use the UseCluster parameter. For more information about Hyper-V live migration, see What's New in Hyper-V in Windows Server 2008 R2 (http://go.microsoft.com/fwlink/?LinkId=147115).
Virtual Machine Migration Compatibility
When you use the Get-VMHostRating cmdlet to get the host ratings for a single VMM host that is running Windows Server 2008 R2 or VMware, the cmdlet performs a direct validation of the running state of the virtual machine against the host to ensure migration compatibility of the virtual machine. Performing a direct validation might take several seconds to complete.
If you use the Get-VMHostRating cmdlet to compare a virtual machine against an array of hosts, the cmdlet will not perform a direct validation of the hosts to produce host ratings. To ensure migration compatibility, you should perform a direct validation by running the Get-VMHostRating cmdlet on each potential target host individually.
For a sample script about how to perform direct validation on a host, see CompatibilityCheck.ps1.
Rapid Provisioning of Virtual Machines
To quickly create virtual machines from a template, you can use the UseLocalVirtualHardDisks parameter of the New-VM cmdlet. This parameter specifies that New-VM use an existing virtual hard disk file stored locally on the destination host instead of copying a virtual hard disk file from the library by using Background Intelligent Transfer Service (BITS). Use the Move-VirtualHardDisk cmdlet to specify the local virtual hard disk file that the virtual machine should connect to in place of the virtual hard disk file that the template points to. You can also add another virtual hard disk to the virtual machine by using the New-VirtualDiskDrive cmdlet and specifying the virtual hard disk. For more information about how to use the UseLocalVirtualHardDisks parameter, type Get-Help New-VM -detailed at the command prompt. For a sample script about how to use rapid provisioning to create a new virtual machine, see RapidProvisionVM.ps1 or RapidProvisionVMwithAnswerFile.ps1. For a sample script about how to use rapid provisioning to recover a virtual machine, see RecoverVMUsingRapidProvisioning.ps1.
Quick Storage Migration
For a Windows Server 2008 R2 host or a VMware Storage VMotion-capable host, you can use the Move-VirtualHardDisk cmdlet together with the Move-VM cmdlet to migrate a running virtual machine and its files (Windows-based .vhd files or VMware-based .vmdk files) to a different storage location on the same host or on a different host, with minimal or no service outage. For more information about how to move a running virtual machine and its files, type Get-Help Move-VM –examples at the command prompt.
Maintenance Mode for Hosts
In VMM 2008 R2, you can start maintenance mode for a Windows-based host anytime you need to perform maintenance tasks (such as applying updates or replacing a physical component) on the host.
When you use the Disable-VMHost cmdlet to place a Windows Server 2008 R2 clustered host into maintenance mode, you can choose one of the following:
If live migration is available, evacuate all highly available virtual machines to other hosts on the same cluster. Virtual machines that are not highly available are placed into a saved state.
Place all virtual machines on the host into a saved state.
When you place a stand-alone Windows-based host or a host within a Windows Server 2008 cluster into maintenance mode, VMM automatically places all the virtual machines into a saved state.
While in maintenance mode, VMM automatically does the following:
It blocks virtual machine creation operations on the host.
It excludes the host from the host ratings during placement.
It sets the value for the host state property to
In Maintenance Mode.
For more information about Disable-VMHost, type Get-Help Disable-VMHost –detailed at the command prompt.
After you have used the Enable-VMHost cmdlet to remove the host from maintenance mode and to place it back in service, VMM does the following:
It allows virtual machine creation on the host.
It includes the host in the host rating calculations during placement.
It sets the value for the host state property back to the host's current state.
However, VMM does not automatically move highly available virtual machines back onto the host, and it does not restart any of the virtual machines that were placed in a saved state. For more information about Enable-VMHost, type Get-Help Enable-VMHost –detailed at the command prompt. For a sample script about how to place clustered hosts into maintenance mode, see MaintenanceModeInCluster.ps1.