How to retrieve information of virtual machine that is running on a Hyper-V host by using PowerShell.
Get-VM -ComputerName VM1,VM2 | Select Computername,Name,State,` @{l="Gen";e={$_.Generation}},` CreationTime,` #@{l="Created";e={"{0:dd.MM.yyyy}" -f $_.CreationTime}},` @{l="Uptime";e={$_.uptime}},` #@{l="Uptime";e={"$($_.uptime.days)d$($_.uptime.hours)h$($_.uptime.minutes)m$($_.uptime.seconds)s"}},` #@{l="Uptime1";e={"{0:00d}/{1:00h}:{2:00m}.{3:00s}" -f $($_.uptime.days),$($_.uptime.hours),$($_.uptime.minutes),$($_.uptime.seconds)}},` @{l="CPUs";e={$_.ProcessorCount}},` @{l="MemoryMB";e={($_.memoryassigned/1MB)}},` @{l="MemoryMin";e={$_.MemoryMinimum/1MB}},` @{l="MemoryMax";e={$_.MemoryMaximum/1MB}},` @{l="MacAddress";e={$_.networkadapters.macaddress}} | FT -AutoSize
This is only a n example please feel free to adjust it to your own needs.
More Stories
Running PowerShell Hyper-V and VMWare Modules
Extend the Evaluation Period on Windows Server
Now using Ansible, Chocolatey, Powershell