Home » PowerShell » Get-Adcomputer- Find Operating System

Get-Adcomputer- Find Operating System

In large organization, as an system administrators its very important to have information about users, computers and other objects in active directory. Often we need information to get adcomputer operating system version which can be helpful to apply policy, upgrade OS job.

In this article, I will explain how to get-adcomputer operating system in active directory, export list of adcomputer operating system to csv file using PowerShell.

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

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

Get-AdComputer Operating System

You can get adcomputer operating system name, version in active directory using 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 character to search within active directory.

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 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 output to second command.

Second command sort by computer name and displays adcomputer operating system, name as 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 requirement to find Windows Server 2019 Datacenter operating system for adcomputer accounts in active directory, use below command

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

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

Output of 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 above article help you to get adcomputer operating system name and operating system version in active directory using Get-AdComputer cmdlet.

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

Leave a Comment