Active Directory is a directory service that stores information about users, computers, and other objects in the Windows network. Often administrators need to retrieve the specific aduser attributes such as department name, for various purposes, including reporting, and access control.
Using the Get-AdUser cmdlet in PowerShell, you can get active directory user information, including their department name.
`Get-AdUser` command in PowerShell is used to get information about users in the Active Directory. It has Department property that contains the department name of the user.
The following PowerShell script will get the aduser department name.
Get-AdUser -Identity arons -Properties * | Select-Object -Property Department
In the above PowerShell script, the Get-Aduser command uses the
Identity parameter to specify the user whose information you want to retrieve, in this case user is named “arons”. The
-Properties * parameter specifies the properties that you want to retrieve, in this case, the
Select-Object cmdlet is used to select the specific properties of an aduser object. The
-Property parameter specifies the properties that you want to select.
The output of the above PowerShell script prints the department name of the user to the console.
Cool Tip: How to get the aduser company name in PowerShell!
I hope the above article on how to retrieve the get aduser department name using the PowerShell Get-AdUser cmdlet is helpful to you.
Properties * parameter is used to retrieve all the properties of the user object.
You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.