Home » PowerShell » Get-Adcomputer- Find Operating System

Get-Adcomputer- Find Operating System

The command to find the operating system name, and version of the computer in the Active directory is Get-AdComputer. This command has an OperatingSystem property that gets the operating system name.

PowerShell Get AdComputer Operating System
PowerShell Get AdComputer Operating System

PowerShell Get-AdComputer cmdlet in the active directory gets one or more active directory computer accounts using search criteria. It has an operating system name, and version attribute.

In a large organization, as a system administrator, it’s very important to have information about users, computers, and other objects in the active directory. Often we need the information to get adcomputer operating system version which can be helpful to apply policy, and upgrade OS jobs.

In this article, we will discuss how to get-adcomputer operating system in an active directory, and export a list of adcomputer operating systems to csv file using PowerShell.

Let’s understand using Get-AdComputer to find operating system with examples below

Get-AdComputer Operating System

You can get adcomputer operating system name, and version in the active directory using the below command

 Get-ADComputer -filter * -Properties * | Select Name, OperatingSystem

In the above PowerShell script, it gets Get-AdComputer Operating System and Name using filter parameter with wildcard characters (*) to search within the active directory.

The output of above command to find adcomputer OS as below

PS C:\Windows\system32> Get-ADComputer -filter * -Properties * | Select Name, OperatingSystem

Name     OperatingSystem
----     ---------------
ENGG-PRO Windows Server 2019 Datacenter
OPER-01  Windows 10 Pro
HR-101   Windows 10 Pro


PS C:\Windows\system32>

Get all ADComputer Operating System in OU

You can get adcomputer operating system name and version details in specific OU using the below command

 Get-ADComputer -filter * -SearchBase "OU=HR,DC=SHELLPRO,DC=LOCAL" -Properties OperatingSystem | Sort Name | Format-Table Name,Enabled,OperatingSystem -AutoSize

In the above PowerShell script, Get-AdComputer get computer account in OU specified by SearchBase criteria and pass the output to the second command.

Second command sorts by computer name and displays adcomputer operating system, name below

PS C:\Windows\system32> Get-ADComputer -filter * -SearchBase "OU=HR,DC=SHELLPRO,DC=LOCAL" -Properties OperatingSystem | Sort Name | Format-Table Name,Enabled,OperatingSystem -AutoSize

Name   Enabled OperatingSystem
----   ------- ---------------
HR-101    True   Windows 10 Pro

HR-102    True   Windows 10 Pro


PS C:\Windows\system32>

Get AdComputer Operating System filter by Server

If you have a requirement to find Windows Server 2019 Datacenter operating system for adcomputer accounts in the active directory, use the below command

Get-ADComputer -Filter {OperatingSystem -like '*Windows Server 2019*'}

In the above PowerShell script, it get adcomputer operating system filter by an operating system like Windows Server 2019

The output of the above command to get adcomputer operating system by server version as below

Get-AdComputer Operating System by Server
Get-AdComputer Operating System by Server

Cool Tip: How to remove adcomputer PowerShell!

Conclusion

I hope the above article helps you to get adcomputer operating system name and operating system version in the active directory using the Get-AdComputer cmdlet.

You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.