- 1 An Azure Lexicon for Working with Virtual Machines in Microsoft Azure
- 2 Creating Azure Virtual Machines Quickly and Painlessly
- 3 Tips and Considerations When Creating Virtual Machines in Azure
- 4 The End of the Road for Windows Server 2003 and 2008
- 5 Move-VM, Move-VMStorage and Compare-VM PowerShell cmdlets for Hyper-V
Working with Windows PowerShell and Hyper-V Modules
Performing a set of common tasks manually in Windows may take a considerable amount of time and can quickly become taxing when the task is a repetitive necessity. For example, if you need to set the memory for ten virtual machines running on Hyper-V, you will need to use the Hyper-V Manager GUI and then edit the settings for all ten virtual machines.
Fortunately, Microsoft has to put a lot of effort into designing a common framework called PowerShell for scripting Windows components in an easy, straightforward manner.
Windows PowerShell is as robust as unix shell and provides commands or cmdlets for almost all roles and features available on operating systems running Windows Server 2008 and later. With Windows PowerShell you can reduce the time and effort it takes to perform the same set of tasks such as the one illustrated above.
Hyper-V ships with 164 built-in PowerShell cmdlets. These cmdlets range from handling very simple, basic tasks to advanced ones such as live migrations of virtual machines across Hyper-V servers. To get the list of all the available Hyper-V cmdlets, you can use the following command in PowerShell:
Get-Command -Module Hyper-V
This command enumerates the list of Hyper-V cmdlets for both Hyper-V Server and any virtual machines and then shows in the command window as shown in the below screenshot:
The PowerShell cmdlets are also user friendly. Just by looking at the name you can get a sense of what it is all about or you can at least get some idea about the command's functionality. For example, Add-VMNetworkAdapter, as shown in the above screenshot, is used to add a Vritual Machine Network Adaptor.
So if you are looking for a specific cmdlet out of 164 cmdlets, you can type the below command. Let's say you want to list all the cmdlets that have the word "Add" in it:
Get-Command -Module Hyper-V -Name *Add*
The command lists all cmdlets that have "Add" as shown in the below screenshot:
Once you have found the cmdlet, you can use it to perform the tasks of your choice. If you are still unsure what a cmdlet does, you can always use "
Get-Help <Hyper-V cmdlet>" cmdlet to get help and examples on the cmdlet.
There are three switches available to be used with "Get-Help" cmdlet: "-Examples", "-Detailed" and "-Full."
To get help and examples on a specific Hyper-V cmdlet called AddVMNetworkAdapter, you can type the following commands:
Get-Help Add-VMNetworkAdapter -Examples
Get-Help Add-VMNetworkAdapter -Detailed
Get-Help Add-VMNetworkAdapter -Full
Read more on "Server OS Spotlight" »