If you have installed the free Microsoft RSAT tools with the “ActiveDirectory” PowerShell module, here is a quick way to get a list of operating systems used in your environment:
#requires -Module ActiveDirectory Get-ADComputer -Filter * -Properties OperatingSystem, OperatingSystemServicePack, OperatingSystemVersion | Select-Object -Property Name, OperatingSystem, OperatingSystemServicePack, OperatingSystemVersion
This would dump information about all computers. You can restrict the search both to computer names and AD location. The following commands would restrict search to the AD location in $root, and only list computers with names starting with “Serv”:
#requires -Module ActiveDirectory $root = 'OU=North,OU=Clients,DC=yourcompany,DC=com' Get-ADComputer -Filter { Name -like 'Serv*' } -Properties OperatingSystem, OperatingSystemServicePack, OperatingSystemVersion <#-ResultSetSize 10#> -SearchBase $root -SearchScope Subtree | Select-Object -Property Name, OperatingSystem, OperatingSystemServicePack, OperatingSystemVersion