Monitoring Hyper-V utilization and performance
This report gathers information about a Hyper-V server and the VMs running on that server.
Getting ready
You run this recipe on the HV1
Hyper-V host.
How to do it...
- Create a basic report hash table:
$ReportHT = [Ordered] @{}
- Get the host details and add them to the report hash table:
$HostDetails = Get-CimInstance -ClassName Win32_ComputerSystem $ReportHT.HostName = $HostDetails.Name $ReportHT.Maker = $HostDetails.Manufacturer $ReportHT.Model = $HostDetails.Model
- Add the PowerShell version information to the report hash table:
$ReportHT.PSVersion = $PSVersionTable.PSVersion.ToString()
- Add OS information to the report hash table:
$OS = Get-CimInstance -Class Win32_OperatingSystem $ReportHT.OSEdition = $OS.Caption $ReportHT.OSArch = $OS.OSArchitecture $ReportHT.OSLang = $OS.OSLanguage $ReportHT.LastBootTime = $os.LastBootUpTime $Now = Get-Date $UTD = [float] ("{0:n3}" -f (($Now – $OS.LastBootUpTime...