I lifted the code from Ben Armstrong’s MSDN Blog here – so have to give credit where credit is due:
I’ll take it a step further…
I wanted to run this script from my VMM Library instead of on every phyiscal host. So, I modified the script so that you could enumerate the physical hosts managed by VMM and then select the host you want to run the script against.
Type the code into notepad and save as a .ps1 file. Stick it in your VMM Library and from there you can right-click to “Run in PowerShell”.
Here’s the output: