PowerShell Snippet - Find Windows 2008 VMs before EOL

Support for Windows Server 2008 and 2008 R2 ends in January 2020- just two years from the date of this post. Four years ago I put up a script to find XP and 2003 VMs, and I’ve modified this to search a vSphere environment for powered on VMs running Server 2008 as a Guest OS:

 1Get-VM |
 2  Where {$_.PowerState -eq "PoweredOn" -and
 3   ($_.Guest -like "*Server 2008*")} |
 4  get-VMGuest |
 5  select VmName, OSFullName
 6
 7VmName OSFullName
 8------ ----------
 9MyVM1 Microsoft Windows Server 2008 R2 (64-bit)
10MyVM2 Microsoft Windows Server 2008 R2 (64-bit)
11MyVM3 Microsoft Windows Server 2008 (64-bit)
12MyVM4 Microsoft Windows Server 2008 R2 (64-bit)