Should you migrate to Windows Server 2012 R2?
A comprehensive collection of articles, videos and more, hand-picked by our editors
Windows Server 2012 R2 is in general availability, and with it comes a new version of PowerShell. Right now, the...
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
only way to get PowerShell 4.0 is to grab and work with the Windows Management Framework 4.0.
One of the most helpful and useful ways to put PowerShell to work is on Windows virtualization tasks. There's already a huge library of materials available on the Internet for this subject, most notably in a five-part series of TechNet blogs. Amidst this wealth of information, you can find a lot of details and ready-to-run PowerShell scripts to automate a number of virtualization set-up, configuration and maintenance tasks.
TechNet series offers insight to running PowerShell scripts
The information covered in the TechNet series provides an excellent overview of what PowerShell is good for in the virtualization world. The series includes an overview of the Graphical PowerShell Interface and provides scripts to map worker process IDs to VMs, how to create scripts for creating a virtual hard disk (VHD) using PowerShell WMI, how to retrieve the IP address of a Hyper-V VM, how to shut down a guest VM in Hyper-V and how to create a complete virtual network in Hyper-V.
Given some time and a desire to put PowerShell to work, you can do a lot with the toolset. The real benefits come, of course, when you can automate recurring tasks. The leverage increases with the frequency of repetition.
CodePlex provides Hyper-V scripts
Following the introduction of Windows Server 2012, and even more so in Windows Server 2012 R2, the extensible switch makes it easier to work with virtualized infrastructures than in earlier versions. Switch extensions also mean you don't have to replace older definitions with brand-new ones. Instead, you can apply updates and enhancements without having to reinvent the wheel.
There's no place better for providing fodder for such activities than the CodePlex PowerShell Management Library for Hyper-V, where you'll find over 100 cmdlets organized by tasks that include finding and connecting to a VM, discovering and manipulating machine states, backing up or exporting VMs and working with VHD files, just to name a few.
Hyper-V has its own collection of cmdlets
Hyper-V 3.0 and higher ship with over 150 PowerShell cmdlets. You can use PowerShell to show what's available and how to run and use those scripts by typing Get-Command –Module Hyper-V in the normal PowerShell runtime environment (Figure 1).
The help system will provide additional details about any cmdlet you need, and you can search the collection by appending -Name *search* to the preceding input line; where the asterisk characters are wildcards, you'd replace search with the particular string you might like to find, such as add, find and so forth. The Get-Help cmdlet takes cmdlet names as input and can be managed using the -Examples (for code examples), -Detailed (for verbose output) and -Full (for all information) switches. Thus, Get-Help Add_VMNetworkAdapter -Examples shows sample PowerShell scripts to add network adapters to a virtual machine.
To access the Hyper-V module in PowerShell, you have to enable that feature, which requires entering this command:
Add-WindowsFeature Hyper-V -IncludeManagementTools
You must also run the PowerShell Console as administrator to interact with and manage Hyper-V, so be sure to follow these simple steps to get up and going.
About the author:
Ed Tittel is a 30-plus year IT veteran who's worked as a developer, networking consultant, technical trainer, writer and expert witness. Perhaps best known for creating the Exam Cram series, Ed has contributed to over 100 books with titles on information security, Windows OSes and HTML. Ed regularly blogs for TechTarget's IT Career Jump Start and Windows Enterprise Desktop blogs, as well as on Tom's IT Pro and PearsonITCertification.com.