How to Modify AD User Attributes via PowerShell

How to Modify AD User Attributes via PowerShell

September 16, 2021 Active Directory PowerShell 0

In this article, we will see How to Get/Modify the Active Directory User Attributes via PowerShell.

Below command help you to get all AD User attributes and values for the respective user1.
Get-ADUser User1 -Properties * | fl

You can use below command to filter with limited result,

Get-ADUser User1 -Properties * | fl *Date*

How to Modify Single Active Directory Users Attributes?
Set-ADUser -Identity User1 -MobileNumber “+91 xxxxxxxxxx”

How to Modify Bulk Active Directory Users Attributes?

For example, If you need to change the attributes of multiple users.
Create a csv file SamAccountName as column1 & MobileNumber as cloumn2
To update user attributes using the values from the CSV file, run the following PowerShell command:

Import-Csv “C:\CloudApex\AD-Users.csv” | foreach {Set-ADUser -Identity $_.SamAccountName -MobileNumber $_.MobilePhone}

For extensionAttribute and custom attributes can edit values in below format:
Add – adds an attribute value
Replace – replaces an attribute value
Clear – clears an attribute value
Remove — removes one of the attribute values

To add a new value to the extensionAttribute15:
Set-ADUser User1 -Add @{extensionAttribute15 = “Project1”}

To delete/remove/clear an attribute value:
Set-ADUser User1 -Clear “extensionAttribute15”

You can modify/change values of multiple attributes at a time:
Set-ADUser User1 -Replace @{extensionAttribute15=”Project2″}

 3,128 total views,  6 views today

Leave a Reply

Your email address will not be published. Required fields are marked *