In this post, the “Set-ADUser” cmdlet will be demonstrated in detail.
Set-ADUser: Modifying Active Directory Users With PowerShell
As described in the above section, the stated cmdlet is responsible for modifying the properties or the attributes of an Active Directory user.
Example 1: Use the “Set-ADUser” Cmdlet to Set the Properties For a User
To set the properties for a specific user, run the provided command:
In the stated code above:
- First, specify the “Set-ADUser” cmdlet, followed by the “-Identity” parameter having the username value assigned to it.
- Then, add the “-Homepage” parameter and assign the URL specifying the user details.
- After that, specify the “-LogonWorkstations” and assign the workstations to it.
Example 2: Use the “Set-ADUser” Cmdlet to Set the Properties For Multiple Users
Use the below-given cmdlet to set the properties for multiple users:
In the stated code snippet above:
- First, write the “Get-ADUser” cmdlet followed by the “-Filter” parameter having the stated filter values assigned to it.
- Then, specify the “-SearchBase” parameter and specify the stated values to it.
- After that, add another parameter “-Properties” along with the “DisplayName” cmdlet and the “|” pipeline.
- Lastly, add the modulus operator followed by the “Set-ADUser” cmdlet and the “-DisplayName” parameter.
Example 3: Use the “Set-ADUser” Cmdlet to Set Properties For E-Mail Address
If you want to set the properties for email, provided command can be used:
According to the above code snippet:
- First, specify the “Set-ADUser”, followed by the “-Identity” parameter having the value “JamesBen” which is a username assigned to it.
- Then, write the “-Replace” parameter and specify the stated hash-table above.
Example 4: Use the “Get-ADUser” Cmdlet to Get a User and the “Set-ADUser” Cmdlet to Set a Property
In this code illustration, first, the user will be retrieved, and then it can be set as a new user:
In the above code snippet:
- First, define the “Get-ADUser” cmdlet, followed by the “-Identity” parameter and assign the existing username and add the pipeline “|”.
- After that, specify the “Set-ADUser” cmdlet along with the “-Manager” parameter and assign the new user by assigning the username.
That’s all about the PowerShell “Set-ADUser” cmdlet.
Conclusion
The “Set-ADUser” cmdlet modifies the Active Directory user attributes or properties. It modifies the commonly used attributes including name, attribute, etc. This post has explained the “Set-ADUser” cmdlet with the aid of various examples.