In this article, we will look into using PowerShell in order to get some information about Hyper-V Host and VM. I’m using this to simplify on my documentation at the end of the project.
Before we begin, you need to download Powershell Management Library for Hyper-V. To download, go to http://pshyperv.codeplex.com/releases . Current latest version is R2 SP1. Well, most people don't like coding and prefer to use GUI. However, in certain way in order to get the end result faster then PowerShell is the answer.
Let look into some PowerShell command that you can use especially want to document your final result.
Pre-requisite:-
a) .Net Framework
b) Windows Powershell
Installation
a) Extract the zip file and execute install.cmd from command line.
To use the PowerShell, you need to import the Hyper-V Module.
Type:-
Import-Module .\HyperV.psd1 |
Let get started:-
To know which command available, you can export the command to a text file.
Just type
Get-command > C:\command.txt |
Some sample that might be useful:-
1. Get memory information such as dynamic memory on the entire VM
Get-VmMemory |
2. Get virtual cpu information that assign to the VM
Get-VmCpuCount |
3. Get network information such as network type, virtual switch and mac address assign to vm. I often use this command to identify duplicate mac address assign to the VM.
get-VMNic |
4. Get information about virtual cpu on the running vm or per vm basis.
Get-VMProcessor |
5. Get information such as snapshot apply to the vm.
Get-VmSnapshot |
6. Get virtual switch information created on the host
Get-VMSwitch |
That’s all for now, a simple cmdlet. Do explore on other PowerShell cmdlet that get you to another end result that you want.