How to Get-ADComputer -Filter in PowerShell

Waqar Aslam Feb 02, 2024
  1. the Get-ADComputer in PowerShell
  2. the Get-ADComputer -Filter in PowerShell
  3. Get Operating System-Based Computers in PowerShell
How to Get-ADComputer -Filter in PowerShell

This article provides a demonstration of the Get-ADComputer and Get-ADComputer -Filter that is available in PowerShell.

the Get-ADComputer in PowerShell

The Get-ADComputer cmdlet in PowerShell is used in the active directory to get one or more active directory computer accounts based on search parameters. It includes the operating system’s name and the version property.

You may use the Get-Help command, as is customary, to get assistance with the Get-ADComputer cmdlet parameters.

Get-Help Get-ADComputer

The -Identity option lets you define which Active Directory machines should retrieve.

The value for the -Identity parameter, which is used to find the computer object, may be set to be either the distinguishing name of the machine, the GUID of the computer, the Security Identifier (SID) or the account name for the Security Accounts Manager (SAM).

If you want information on a particular computer account in the domain, you may acquire that information by using the name of that account as input for the -Identity parameter. This will bring back the fundamental characteristics of the computer.

Get-ADComputer -Identity PC-01

We can acquire more information from the computer by using the -properties argument. Use the following command to see every piece of information associated with a specific user account on a computer.

Get-ADComputer -Identity PC-01 -properties *

the Get-ADComputer -Filter in PowerShell

Find one or more machines in your Active Directory using the Get-ADComputer cmdlet, another excellent method.

Even if the computer object doesn’t store much information, we can still utilize some of its characteristics to filter the data.

Using the -like filter, we can locate a computer using just a portion of the machine’s name.

Get-ADComputer -Filter "Name -like '*elitebook*'" | ft

Get Operating System-Based Computers in PowerShell

Access to the Active Directory data about individuals, computers, and other items is necessary for system administrators working in big businesses.

They usually need the information to identify the operating system’s version installed on a machine to update the OS or apply a policy.

If you need to search for a certain machine running a certain operating system in Active Directory, use the following command.

Get-ADComputer -Filter { OperatingSystem -like '*Windows 10*' }

We also can use numerous criteria, such as the following, to get all machines running Windows 10 or 11.

Get-ADComputer -Filter "OperatingSystem -eq 'Windows 10' -or OperatingSystem -eq 'Windows 11'" | ft

Using the Export-CSV cmdlet and specifying a destination for the exported data, as illustrated below, allows you to export the results of a cmdlet.

Get-ADComputer -Filter * -Properties * | select Name, OperatingSystem | Export-Csv E:\SaadAslam\List.csv
Author: Waqar Aslam
Waqar Aslam avatar Waqar Aslam avatar

I am Waqar having 5+ years of software engineering experience. I have been in the industry as a javascript web and mobile developer for 3 years working with multiple frameworks such as nodejs, react js, react native, Ionic, and angular js. After which I Switched to flutter mobile development. I have 2 years of experience building android and ios apps with flutter. For the backend, I have experience with rest APIs, Aws, and firebase. I have also written articles related to problem-solving and best practices in C, C++, Javascript, C#, and power shell.

LinkedIn

Related Article - PowerShell Active Directory