Finding EOL Windows Systems Using PowerShell

Asphyxia

Owner
Administrator
Apr 25, 2015
1,844
2
2,197
327
Get-ADComputer -Properties DNSHostName,OperatingSystem,whenChanged -Filter {(OperatingSystem -like "Windows 7*")} | Select DNSHostName,OperatingSystem,whenChanged | findstr "\/2020"

So what does this do? Any systems that are outta date (running Windows 7) at least should show up.. then we are grepping using findstr. We could probably do some REGEX magic shit, to grep things out by month.. for example 2/#/2020.. or 4/#/2020.. for that whenChanged date, if that makes sense?

Lot of useful features within PowerShell using Get-ADComputer.. ;)

This will require the PowerShell AD module: https://4sysops.com/wiki/how-to-install-the-powershell-active-directory-module/

Otherwise you get this error:
PS C:\Users\level1trauma> Get-ADComputer -Properties DNSHostName,OperatingSystem,whenChanged -Filter {(OperatingSystem -like "Windows 7*")} | Select DNSHostName,OperatingSystem,whenChanged | findstr "\/2020"
Get-ADComputer : The term 'Get-ADComputer' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:1 char:1
+ Get-ADComputer -Properties DNSHostName,OperatingSystem,whenChanged -F ...
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-ADComputer:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
 
Last edited:
Top