vBulletin statistics
PowerShell Management Library for Hyper-V R2 - Windows Server blog by Kurt Roggen [BE]
maandag 8 februari 2010 7:41 Kurt Roggen

PowerShell Management Library for Hyper-V R2

The new PowerShell cmdlets for Hyper-V (by James O’Neill) are implemented in the form of a PowerShell version 2 module which is distributed as a single zip file from http://PShyperV.codeplex.com.

A previous version was implemented for version 1 of PowerShell and remains available on CodePlex. The previous version will also work on PowerShell V2, but the new version will not work on PowerShell V1.
Both versions work with the original release of Hyper-V and the R2 release.

The library uses 31 different verbs and 69 different nouns (2139 possible combinations)


To install the Hyper-V module, copy the contents of the “HyperV_Install” folder (inside the zip file) to a new folder “%systemdrive%\Windows\System32\WindowsPowerShell\v1.0\Modules\HyperV”


To find the Hyper-V module, from PowerShell, type

Get-Module -List

Notice the HyperV module is picked up automatically by PowerShell.

To import the Hyper-V module, from PowerShell, type

import-module HyperV

To find out which commands are available through the module, from PowerShell, type

get-command -module HyperV

To get help or more detailed information about a specific cmdlet, from PowerShell, type

get-help <cmdlets>

Some more examples:

Connecting to a VM

Discovering and manipulating Machine states
Get-VMState , Set-VMState , Convert-VmState, Ping-VM , Test-VMHeartBeat, Shutdown-VM , Start-VM, Stop-VM, Suspend-VM, Get-VMKVP, Add-KVP, Remove-KVP, Get-VMJPEG

Backing up, exporting and snapshotting VMs
Export-VM , Import-VM, Get-VMSnapshot, Choose-VMSnapshot , Apply-VMSnapshot , New-VMSnapshot ,Remove-VMSnapshot, Rename-VMSnapShot, Update-VMSnapshot, Get-VMSnapshotTree, Get-VmBackupScript

Adding and removing VMs, configuring motherboard settings.
New-VM , Remove-VM , Set-VM , Get-VMCPUCount, Set-VMCPUCount, Get-VMMemory, Set-VMMemory, Set-VMSerialPort

Manipulating Disk controllers, drives and disk images
Add-VMSCSIController , Remove-VMSCSIcontroller
Get-VMDriveByController , Add-VMDRIVE , Remove-VMdrive
Get-VMDiskByDrive, Add-VMDisk , Set-VMDisk, Get-VMDisk
Get-VMFloppyDisk , Add-VMFloppyDisk

Manipluating Network Interface Cards
Get-VMNic , List-VMNic , Choose-VMNIC, Add-VMNIC, Remove-VMNIC , Set-VMNICAddress , Set-VMNICConnection , Get-VMNicport,
Get-VMNicSwitch, Choose-VMSwitch, New-VMSwitchPort, Get-VMByMACaddress, Choose-VMExternalEthernet,
New-VMExternalSwitch, New-VMInternalSwitch, New-VmPrivateSwitch

Working with VHD files
Get-VHDDefaultPath, Get-VHDInfo, New-VHD, Compact-VHD, Test-VHD,Convert-VHD,Merge-VHD,Mount-VHD, Unmount-VHD


Download Hyper-V R2 PS Library documentation here

Download Hyper-V R2 PS Library here

Filed under: , ,