Hyper-V PowerShell in Windows 8 CTP

Author by Nathan Lasnoski

The Hyper-V platform in Windows 8 now has PowerShell!  This is awesome, as it has enabled both automation opportunities, as well as command line ease of use.  I'm certain that the use of PowerShell throughout the Windows 8 platform will make the core installation types much more popular.  I've done some playing around and provided some information about the upcoming PowerShell commandlets below.   I've included the full command listing, as well as some common command usages.  In this series I'll also walk through common Hyper-V PowerShell examples that we'll need for automation.  

Full List of Hyper-V Commands

  PS C:Windowssystem32> Get-Command -Module Hyper-V   CommandType     Name                               ModuleName                         Definition                       -----------     ----                               ----------                         ----------                       Cmdlet          Add-VMDvdDrive                     Hyper-V                            ...                              Cmdlet          Add-VMFibreChannelHba              Hyper-V                            ...                              Cmdlet          Add-VMHardDiskDrive                Hyper-V                            ...                              Cmdlet          Add-VMMigrationNetwork             Hyper-V                            ...                              Cmdlet          Add-VMNetworkAdapter               Hyper-V                            ...                              Cmdlet          Add-VMNetworkAdapterAcl            Hyper-V                            ...                              Cmdlet          Add-VMRemoteFx3dVideoAdapter       Hyper-V                            ...                              Cmdlet          Add-VMScsiController               Hyper-V                            ...                              Cmdlet          Add-VMStoragePath                  Hyper-V                            ...                              Cmdlet          Add-VMSwitch                       Hyper-V                            ...                              Cmdlet          Add-VMSwitchExtensionFeature       Hyper-V                            ...                              Cmdlet          Checkpoint-VM                      Hyper-V                            ...                              Cmdlet          Compare-VM                         Hyper-V                            ...                              Cmdlet          Complete-VMFailover                Hyper-V                            ...                              Cmdlet          Connect-VMNetworkAdapter           Hyper-V                            ...                              Cmdlet          Connect-VMSan                      Hyper-V                            ...                              Cmdlet          Convert-VHD                        Hyper-V                            ...                              Cmdlet          Disable-VMIntegrationService       Hyper-V                            ...                              Cmdlet          Disable-VMMigration                Hyper-V                            ...                              Cmdlet          Disable-VMResourceMetering         Hyper-V                            ...                              Cmdlet          Disable-VMSwitchExtension          Hyper-V                            ...                              Cmdlet          Disconnect-VMNetworkAdapter        Hyper-V                            ...                              Cmdlet          Disconnect-VMSan                   Hyper-V                            ...                              Cmdlet          Dismount-VHD                       Hyper-V                            ...                              Cmdlet          Enable-VMIntegrationService        Hyper-V                            ...                              Cmdlet          Enable-VMMigration                 Hyper-V                            ...                              Cmdlet          Enable-VMResourceMetering          Hyper-V                            ...                              Cmdlet          Enable-VMSwitchExtension           Hyper-V                            ...                              Cmdlet          Export-VM                          Hyper-V                            ...                              Cmdlet          Export-VMSnapshot                  Hyper-V                            ...                              Cmdlet          Get-VHD                            Hyper-V                            ...                              Cmdlet          Get-VM                             Hyper-V                            ...                              Cmdlet          Get-VMBios                         Hyper-V                            ...                              Cmdlet          Get-VMComPort                      Hyper-V                            ...                              Cmdlet          Get-VMConnectAccess                Hyper-V                            ...                              Cmdlet          Get-VMDvdDrive                     Hyper-V                            ...                              Cmdlet          Get-VMFibreChannelHba              Hyper-V                            ...                              Cmdlet          Get-VMFloppyDiskDrive              Hyper-V                            ...                              Cmdlet          Get-VMHardDiskDrive                Hyper-V                            ...                              Cmdlet          Get-VMHost                         Hyper-V                            ...                              Cmdlet          Get-VMHostNumaNode                 Hyper-V                            ...                              Cmdlet          Get-VMHostNumaNodeStatus           Hyper-V                            ...                              Cmdlet          Get-VMIdeController                Hyper-V                            ...                              Cmdlet          Get-VMIntegrationService           Hyper-V                            ...                              Cmdlet          Get-VMMemory                       Hyper-V                            ...                              Cmdlet          Get-VMMigrationNetwork             Hyper-V                            ...                              Cmdlet          Get-VMNetworkAdapter               Hyper-V                            ...                              Cmdlet          Get-VMNetworkAdapterAcl            Hyper-V                            ...                              Cmdlet          Get-VMNetworkAdapterFailoverCon... Hyper-V                            ...                              Cmdlet          Get-VMNetworkAdapterVlan           Hyper-V                            ...                              Cmdlet          Get-VMProcessor                    Hyper-V                            ...                              Cmdlet          Get-VMRemoteFx3dVideoAdapter       Hyper-V                            ...                              Cmdlet          Get-VMReplication                  Hyper-V                            ...                              Cmdlet          Get-VMReplicationAuthorizationE... Hyper-V                            ...                              Cmdlet          Get-VMReplicationServer            Hyper-V                            ...                              Cmdlet          Get-VMResourcePool                 Hyper-V                            ...                              Cmdlet          Get-VMSan                          Hyper-V                            ...                              Cmdlet          Get-VMScsiController               Hyper-V                            ...                              Cmdlet          Get-VMSnapshot                     Hyper-V                            ...                              Cmdlet          Get-VMStoragePath                  Hyper-V                            ...                              Cmdlet          Get-VMSwitch                       Hyper-V                            ...                              Cmdlet          Get-VMSwitchExtension              Hyper-V                            ...                              Cmdlet          Get-VMSwitchExtensionFeature       Hyper-V                            ...                              Cmdlet          Get-VMSystemSwitchExtension        Hyper-V                            ...                              Cmdlet          Get-VMSystemSwitchExtensionFeature Hyper-V                            ...                              Cmdlet          Grant-VMConnectAccess              Hyper-V                            ...                              Cmdlet          Import-VM                          Hyper-V                            ...                              Cmdlet          Import-VMInitialReplication        Hyper-V                            ...                              Cmdlet          Measure-VM                         Hyper-V                            ...                              Cmdlet          Measure-VMReplication              Hyper-V                            ...                              Cmdlet          Measure-VMResourcePool             Hyper-V                            ...                              Cmdlet          Merge-VHD                          Hyper-V                            ...                              Cmdlet          Mount-VHD                          Hyper-V                            ...                              Cmdlet          Move-VM                            Hyper-V                            ...                              Cmdlet          Move-VMStorage                     Hyper-V                            ...                              Cmdlet          New-VFD                            Hyper-V                            ...                              Cmdlet          New-VHD                            Hyper-V                            ...                              Cmdlet          New-VM                             Hyper-V                            ...                              Cmdlet          New-VMReplicationAuthorizationE... Hyper-V                            ...                              Cmdlet          New-VMResourcePool                 Hyper-V                            ...                              Cmdlet          New-VMSan                          Hyper-V                            ...                              Cmdlet          New-VMSwitch                       Hyper-V                            ...                              Cmdlet          Optimize-VHD                       Hyper-V                            ...                              Cmdlet          Remove-VM                          Hyper-V                            ...                              Cmdlet          Remove-VMDvdDrive                  Hyper-V                            ...                              Cmdlet          Remove-VMFibreChannelHba           Hyper-V                            ...                              Cmdlet          Remove-VMHardDiskDrive             Hyper-V                            ...                              Cmdlet          Remove-VMMigrationNetwork          Hyper-V                            ...                              Cmdlet          Remove-VMNetworkAdapter            Hyper-V                            ...                              Cmdlet          Remove-VMNetworkAdapterAcl         Hyper-V                            ...                              Cmdlet          Remove-VMRemoteFx3dVideoAdapter    Hyper-V                            ...                              Cmdlet          Remove-VMReplication               Hyper-V                            ...                              Cmdlet          Remove-VMReplicationAuthorizati... Hyper-V                            ...                              Cmdlet          Remove-VMResourcePool              Hyper-V                            ...                              Cmdlet          Remove-VMSan                       Hyper-V                            ...                              Cmdlet          Remove-VMSavedState                Hyper-V                            ...                              Cmdlet          Remove-VMScsiController            Hyper-V                            ...                              Cmdlet          Remove-VMSnapshot                  Hyper-V                            ...                              Cmdlet          Remove-VMStoragePath               Hyper-V                            ...                              Cmdlet          Remove-VMSwitch                    Hyper-V                            ...                              Cmdlet          Remove-VMSwitchExtensionFeature    Hyper-V                            ...                              Cmdlet          Rename-VM                          Hyper-V                            ...                              Cmdlet          Rename-VMResourcePool              Hyper-V                            ...                              Cmdlet          Rename-VMSan                       Hyper-V                            ...                              Cmdlet          Rename-VMSnapshot                  Hyper-V                            ...                              Cmdlet          Rename-VMSwitch                    Hyper-V                            ...                              Cmdlet          Repair-VM                          Hyper-V                            ...                              Cmdlet          Reset-VMResourceMetering           Hyper-V                            ...                              Cmdlet          Resize-VHD                         Hyper-V                            ...                              Cmdlet          Restart-VM                         Hyper-V                            ...                              Cmdlet          Restore-VMSnapshot                 Hyper-V                            ...                              Cmdlet          Resume-VM                          Hyper-V                            ...                              Cmdlet          Resume-VMReplication               Hyper-V                            ...                              Cmdlet          Revoke-VMConnectAccess             Hyper-V                            ...                              Cmdlet          Save-VM                            Hyper-V                            ...                              Cmdlet          Set-VHD                            Hyper-V                            ...                              Cmdlet          Set-VM                             Hyper-V                            ...                              Cmdlet          Set-VMBios                         Hyper-V                            ...                              Cmdlet          Set-VMComPort                      Hyper-V                            ...                              Cmdlet          Set-VMDvdDrive                     Hyper-V                            ...                              Cmdlet          Set-VMFibreChannelHba              Hyper-V                            ...                              Cmdlet          Set-VMFloppyDiskDrive              Hyper-V                            ...                              Cmdlet          Set-VMHardDiskDrive                Hyper-V                            ...                              Cmdlet          Set-VMHost                         Hyper-V                            ...                              Cmdlet          Set-VMMemory                       Hyper-V                            ...                              Cmdlet          Set-VMMigrationNetwork             Hyper-V                            ...                              Cmdlet          Set-VMNetworkAdapter               Hyper-V                            ...                              Cmdlet          Set-VMNetworkAdapterFailoverCon... Hyper-V                            ...                              Cmdlet          Set-VMNetworkAdapterVlan           Hyper-V                            ...                              Cmdlet          Set-VMProcessor                    Hyper-V                            ...                              Cmdlet          Set-VMRemoteFx3dVideoAdapter       Hyper-V                            ...                              Cmdlet          Set-VMReplication                  Hyper-V                            ...                              Cmdlet          Set-VMReplicationAuthorizationE... Hyper-V                            ...                              Cmdlet          Set-VMReplicationServer            Hyper-V                            ...                              Cmdlet          Set-VMResourcePool                 Hyper-V                            ...                              Cmdlet          Set-VMSan                          Hyper-V                            ...                              Cmdlet          Set-VMSwitch                       Hyper-V                            ...                              Cmdlet          Start-VM                           Hyper-V                            ...                              Cmdlet          Start-VMFailover                   Hyper-V                            ...                              Cmdlet          Start-VMInitialReplication         Hyper-V                            ...                              Cmdlet          Stop-VM                            Hyper-V                            ...                              Cmdlet          Stop-VMFailover                    Hyper-V                            ...                              Cmdlet          Stop-VMInitialReplication          Hyper-V                            ...                              Cmdlet          Stop-VMReplication                 Hyper-V                            ...                              Cmdlet          Suspend-VM                         Hyper-V                            ...                              Cmdlet          Suspend-VMReplication              Hyper-V                            ...                              Cmdlet          Test-VHD                           Hyper-V                            ...                              Cmdlet          Update-VMSwitchExtensionFeature    Hyper-V                            ...     

Get VM Listing

PS C:Windowssystem32> Get-VM  Name            State CPU(%) AssignedMemory(M) MemoryDemand(M) MemoryStatus Uptime   Status             ReplicationStat ----            ----- ------ ----------------- --------------- ------------ ------   ------             --------------- CNCYREPLICATEST Off   0                        0                            00:00:00 Operating normally Disabled    

Get-VM Information for Specific VM

PS C:Windowssystem32> Get-VM "CNCYREPLICATEST"  Name            State CPU(%) AssignedMemory(M) MemoryDemand(M) MemoryStatus Uptime   Status             ReplicationStat   ----            ----- ------ ----------------- --------------- ------------ ------   ------             --------------- CNCYREPLICATEST Off   0                        0                            00:00:00 Operating normally Disabled    

Get All VM Information for Specific VM

PS C:Windowssystem32> Get-VM "CNCYREPLICATEST" | fl Name             : CNCYREPLICATEST State            : Off CpuUsage         : 0 AssignedMemory   : MemoryDemand     : 0 MemoryStatus     : Uptime           : 00:00:00 Status           : Operating normally ReplicationState : Disabled  

Get VM Host Information 

PS C:Windowssystem32> Get-VMHost   DefaultVirtualHardDiskLocation        : C:Hyper-V DefaultVirtualMachineLocation         : C:Hyper-V FullyQualifiedDomainName              : concurrency.com Name                                  : CNCYVSVR14 MinimumMacAddress                     : 00155D496500 MaximumMacAddress                     : 00155D4965FF MaximumSimultaneousStorageMigrations  : 2 MaximumSimultaneousLiveMigrations     : 2 InboundVirtualMachineMigrationEnabled : False FibreChannelWorldWideNodeName         : C0:03:FF:00:00:FF:FF:00 FibreChannelWorldWidePortNameMaximum  : C0:03:FF:3D:2D:2C:FF:FF FibreChannelWorldWidePortNameMinimum  : C0:03:FF:3D:2D:2C:00:00 LogicalProcessorCount                 : 4 MemoryCapacity                        : 8415461376 ResourceMeteringSaveInterval          : 01:00:00 NumaSpanningEnabled                   : True HostNumaStatus                        : NumaStatus                            : InternalNetworkAdapters               : {}  

New VM Creation

PS C:Windowssystem32> New-VM -?   NAME     New-VM   SYNTAX     New-VM [[-Name] ] [[-MemoryStartupBytes] ] [-BootDevice ] [-NoVHD] [-SwitchName ] [-AsJob] [-ComputerName ] [-WhatIf] [-Confirm] []       New-VM [[-Name] ] [[-MemoryStartupBytes] ] [-BootDevice ] [-SwitchName ] -N     -NewVHDSize [-Path ] [-AsJob] [-ComputerName ] [-WhatIf] [-Confirm]     []       New-VM [[-Name] ] [[-MemoryStartupBytes] ] [-BootDevice ] [-SwitchName ] -V     [-Path ] [-AsJob] [-ComputerName ] [-WhatIf] [-Confirm] []   I'm excited to work more with VM automation.  Stay tuned for some cool examples!   Nathan Lasnoski
Author

Nathan Lasnoski

Chief Technology Officer