Friday, October 4, 2024
HomePowershellRetrieve and doc all Hyper-V VMs – SID-500.COM

Retrieve and doc all Hyper-V VMs – SID-500.COM


On this submit I’ll present the right way to retrieve all Hyper-V VMs and save the output. That is particularly useful if you wish to convey an outline into your chaos. Let’s dive in.

I’ve many VMs in operation and that is what they seem like:

A superb overview, however not ok. Now let’s go. We’ll get a very powerful details about these digital computer systems with PowerShell.

Open PowerShell, ISE or VS Code.

Execute the next command to retrieve vital information of your VMs.

Please word that I’ve already formatted the output, since you gained’t like the usual output, consider me. By the best way, I hate record outputs.

Get-VM | Choose-Object Title,ProcessorCount,`
@{identify="Reminiscence";expression={[math]::Spherical($_.MemoryAssigned/1GB,0).tostring() + ' GB'}},`
@{n='Uptime';e={(Get-Date) - $_.Uptime}},State,Model | Format-Desk

This offers you the output beneath.

Lastly, we will save the output to a file. Both in a txt file or as an HTML file.

TXT
Get-VM | Choose-Object Title,ProcessorCount,`
@{identify="Reminiscence";expression={[math]::Spherical($_.MemoryAssigned/1GB,0).tostring() + ' GB'}},`
@{n='Uptime';e={(Get-Date) - $_.Uptime}},State,Model | Out-File $homevms.txt
HTML
Get-VM | Choose-Object Title,ProcessorCount,`
@{identify="Reminiscence";expression={[math]::Spherical($_.MemoryAssigned/1GB,0).tostring() + ' GB'}},`
@{n='Uptime';e={(Get-Date) - $_.Uptime}},State,Model | 
ConvertTo-Html | Out-File $homevms.html

That’s it for right this moment.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments