O'Reilly logo

Microsoft System Center Virtual Machine Manager 2012 Cookbook by Edvaldo Alessandro Cardoso

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

VMM sample scripts

The sample scripts in this recipe illustrate how to use Windows PowerShell for centralized management.

You can use VMM PowerShell cmdlets to automate VMM tasks by executing them from a machine with the VMM console installed.

The following section contains some samples to add storage and convert the VHD disk format to the VHDX disk format.

How to do it...

You can use PowerShell scripts to automate various tasks. The following sample script counts the number of VMs per OS.

Counting the number of virtual machines per operating system

Import-Module virtualmachinemanager
$vHosts = Get-SCVMHost
foreach ($vHost in $vHosts){ 
 Get-SCVirtualMachine -VmHost $vHost | Group-Object OperatingSystem | Sort Count –Descending | Select Name, Count ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required