PowerShell

PowerShell: List and document all Hyper-V VMs with the most important properties

So you have multiple Hyper-V VMs and may have lost track of them. In this post I will show you how to retrieve all Hyper-V VMs with the most important properties and settings. With PowerShell of course – what else.

Run this little nice script to get the most important properties of your VMs.

Get-VM | Select-Object Name,ProcessorCount,`
@{name='MemoryStartup';expression={[math]::Round($_.MemoryStartup/1GB,0).tostring() + ' GB'}},`
@{name='MemoryAssigned';expression={[math]::Round($_.MemoryAssigned/1GB,0).tostring() + ' GB'}},`
@{n='Uptime';e={(Get-Date) - $_.Uptime}},State,Version | Format-Table

Now you have a nice overview of your VMs.

By the way, you can of course save the output to a file.

Get-VM | Select-Object Name,ProcessorCount,`
@{name='MemoryStartup';expression={[math]::Round($_.MemoryStartup/1GB,0).tostring() + ' GB'}},`
@{name='MemoryAssigned';expression={[math]::Round($_.MemoryAssigned/1GB,0).tostring() + ' GB'}},`
@{n='Uptime';e={(Get-Date) - $_.Uptime}},State,Version | Convertto-HTML | Out-File $home\vms.html

1 reply »

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.