PowerShell and HyperV

An update of the PowerShell library for Hyper-V has been posted to Codeplex.

This is the R2 version which takes advantage of PowerShell 2 which is available on R2 versions of Hyper-V server and Core installations of Windows Server. It will manage Hyper-V on the original release of Server 2008 provided it is running in a the V2 of PowerShell.

The original library allowed the creation and maintenance of VHD files, creating and deleing VMs, starting, stopping and saving them, managing their settings, taking and applying snapshots and configuration of the Hyper-V host. The following changes were made for the R2:

  • Implemented as a PowerShell V2 module, rather an script to get started type Import-Module Hyperv (or add that to your PowerShell profile)
  • Support for PowerShell on-line help (also new to V2). Get-Help command name works the same as it does for built-in commands
  • Support for Powershell common parameters (again, new in PowerShell V2). You can now use –whatif and –confirm switches if you are uncertain what a command will do
  • Greater flexibility for Piping the output of commands into other commands (previously some kinds of disk object could be piped, and some could not. This too leverages new stuff in PowerShell V2 See this blog post for more background). 
  • Support for a menu front end (see Screen shots below)
  • Language specific information has been moved to its own file, so the module can be localized easily.

In addition this “Gold” release adds support in two areas which were not in earlier R2 builds.

  • Support for Clustering – on server 2008 R2 only, if the FailoverClusters Module has been loaded
  • Support for PowerShell remoting [though this has had minimal testing to date]

There is a video showing the module in action on Technet Edge

There are now 122 functions, and 16 aliases for backwards compatibility so that any scripts written for V1 of the library should not break. V1 continues to be available for server 2008 customers who have not upgraded to PowerShell V2.  The RC has had a large number of downloads and very few bug reports (all of which have been fixed). The scope of changes between RC and this build meant it is designated as “Gold” rather than “Release”, it is expected that there minor errors in the on-line help, which will be properly proof read and corrected  before release is declared.

Feedback of all kinds is welcome (via codeplex or via this blog).

HV1

Top level menu. Note that Cluster networks for Live Migration and cluster shared volumes are displayed. [This allows the path to a CSV to be copied and pasted into the Create virtual machine part of the menu], and there is a menu Item to Live Migrate Virtual Machines.

hv-vmmenu

VM menu, note that the cluster status of this machine shows as on-line. Machines can be moved between cluster nodes , or set as highly available. 

hv-diskmenu2

 

 

Disk management menu for a VM.