The “Get-AdUser” cmdlet is used to retrieve one or more Active Directory users in PowerShell. Moreover, it gets the user object specified by the user. It can also perform a search to retrieve a number of user objects. The “-Identity” parameter is used with the stated cmdlet to identify the user by its distinguished name or by its security identifier (SAM).
In this post, the “Get-ADUser ” cmdlet will be discussed.
Get-ADUser: Finding Active Directory Users With PowerShell
As described above, the stated cmdlet is responsible for getting the list of users based on the parameters provided.
Let’s have a look at the examples related to the stated cmdlet.
Example 1: Use the “Get-ADUser” Cmdlet to Get All the Users in the Container
To get the list of all the users in the specified container, run the provided cmdlet:
According to the above code:
- First, write the “Get-ADUser” cmdlet, followed by the “-Filter” parameter and the “*” wildcard.
- After that, create another parameter “-SearchBase” parameter and assign the stated value.
Example 2: Use the “Get-ADUser” Cmdlet to Retrieve a List of Filtered Users
The below-given demonstration can be used to get the filtered list of users:
In the above-stated code:
- First, specify the “Get-ADUser” cmdlet along with the “-Filter” parameter having the stated filter assigned to it.
- In the created filter, first, add the “Name” followed by the “-like” parameter and assign the string value “*SvcAccount”.
- After that, add the “|” pipeline along with the “Format-Table” cmdlet having the values “Name” and “SamAccountName”.
- Lastly, add the “-A” parameter.
Example 3: Use the “Get-ADUser” Cmdlet to Get the Properties of a Specified User
To list down the properties of a specified user execute the given command:
In the above-given code snippet:
- First, specify the “Get-ADUser” cmdlet along with the “-Identity” parameter having the value “JamesBen” assigned to it.
- Lastly, specify the “-Properties” parameter and add the “*” wildcard.
Example 4: Use the “Get-ADUser” Cmdlet to Get a Specified User
To retrieve the user specified in the code, run the provided cmdlet:
In the above-given code:
- First, specify the “Get-ADUser” cmdlet, along with the “-Filter” cmdlet, and assign the stated filter.
- After that, add the “-SearchBase”, “-Properties”, and the “-Server” parameters. Then, assign the stated values to them.
Example 5: Use the “Get-ADUser” Cmdlet to Get the List of All enabled Users With the Help of the “-LDAPFilter” Parameter
Get the list of all enabled users with the help of the “-LDAPFilter” parameter, as follows:
According to the above code, first, specify the “Get-ADUser” cmdlet followed by the “-LDAPFilter” parameter and assign the stated value.
That’s all about the “Get-ADUser” cmdlet for finding the active dictionary users with PowerShell.
Conclusion
The cmdlet “Get-ADUser” is used to retrieve the chosen user object or conduct a search to obtain a list of several user objects. Moreover, a customized list of users can be retrieved with the aid of several parameters. This post has elaborated on the “Get-ADUser” cmdlet in detail.