Manage Users Using Active Directory PowerShell Module and The Get-ADUSER cmdlet

With the release of my latest weekly series about Active Directory Management using PowerShell and Yesterday’s post today I’ll focus on a core cmdlet In the AD Module.

The Get-ADUser cmdlet Is a core cmdlet because It’s allowing us to query Individual users based on their DN Name, GUID, SID, UPN, SAM account, Account Name or Name.

The most basic usage form Is:

Get-Aduser David

To get all the users In the directory use:

Get-aduser -filter * | ft

To search for users with specific attributes use:

Note: the cmdlet below Is the most powerful cmdlet in the module because you could pipe the results and modify the data of each user as I’ll show In my next article.

Get-ADUser -filter "department -like '42' " -Properties *| select name,department

I can also use a CSV file with a list of uses as seen below to extract specific data from AD:

Import-csv .\smtp.csv | foreach {get-aduser -identity $_.upn} select, samaccountname, userprincipalname, name

To search for users In a specific OU use (In my case I’m looking for all users In the Dev OU that their name start with D:

Get-aduser -filter {name -like "d*"} -searchbase "ou=dev,dc=test,dc=local" | ft

Leave a Reply