In this post, you will learn how to get the Windows operating system version of computers in Active Directory. I’ll show you how to list the operating system version and build number by using PowerShell and the AD Pro Toolkit.
Computer objects in Active Directory have an operatingSystem and operatingSystemVersion attribute that can be used to look up operating system details. This means you don’t have to connect to each computer to find out the OS version, you can easily get the details directory from Active Directory.
Get Windows OS version using PowerShell
Example 1. Get all domain computers OS version
Get-ADComputer -filter * -property * | select Name,OperatingSystem, OperatingSystemVersion
In this example, I get the OS version of all computers in Active Directory. I use the select parameter to limit the attributes to the computer Name, OperatingSystem and OperatingSystemVersion.
Example 2. Get OS version from all computers in an OU
Get-ADComputer -Filter * -SearchBase "OU=ADPRO Computers,DC=ad,DC=activedirectorypro,DC=com" -property * | select Name,OperatingSystem, OperatingSystemVersion,distinguishedName
In this example, I get the OS version of all computers from a specific OU. To get all the computers from an OU you will use the -SearchBase parameter and the distinguishedName of the OU.
Example 3. Get all computers with server operating system
Get-ADComputer -Filter {OperatingSystem -Like "Windows Server*"} -Property * | select Name,OperatingSystem,OperatingSystemVersion
In this example, I find all computers in Active Directory that have a server operating system. I use the -Like PowerShell operator to filter for computers where the “OperatingSystem” attribute matches the string “Windows Server”.
Example 4. Get all computers with client operating system (Windows 10/11)
Get-ADComputer -Filter {OperatingSystem -NotLike "Windows Server*"} -Property * | select Name,OperatingSystem,OperatingSystemVersion
In this example, I find all computers in Active Directory that have a client operating system. I use the -NotLike operator to filter for computers where the “OperatingSystem” attribute does not match “Windows Server”. So basically, this finds all computers that are not a server operating system.
Example 5. Get a count of all computers in Active Directory
(get-adcomputer -filter *).count
In this example, I get the total count of all computers in the domain. This is useful so you can quickly get a count of how many computer objects are in your domain.
Get Windows OS Versions using AD Pro Toolkit
The AD Pro Toolkit includes multiple AD Computer Reports to quickly inventory your Active Directory environment. All reports can be automated, customized, sent via email and exported out to a file.
- Click on “Computer Reports”
- Select the “All Computers”
- Click “Run” to generate the report.
- To export the report (csv, excel or pdf) click the export button.
Example report of all computers using the AD Reporting Tool.
You can try the AD Pro Toolkit for free by clicking the download button below.
Download Free TrialGet a count of all computers with OS version
Click on “Computer Reports” and select “All Computers by OS count” report.
The above report is a quick way to get an inventory of what computers you have in your domain.
Get Computers with specific Operating System
Click on “Computer Reports” and select “OS based report”.
Select the OS and click “Run”.
Try AD Pro Toolkit for FreeConclusion
In this post, I showed you two options on how to get the Windows operating system version of computers in Active Directory. With the Get-ADComputer cmdlet you can filter computer objects by the operatingSystem and operatingSystemVersion attributes. You can use various PowerShell filters and operators to limit the results to specific Windows versions and build numbers. If you don’t have the time to mess with PowerShell, then the AD Pro Toolkit makes it very easy to get all computers and their OS details. With the Toolkit you can run computer reports in just a few clicks of the mouse and easily export and automate reports.