Powershell – How to change AD user description field

7

Hello All,

Its been some time that I wrote an article, but today we will seeing how to change AD user description field in Active Directory.

Of course we will be using Powershell to perform this. But be aware that we can do this from Active Directory Users and Computers as well.

Let us say that we have a user Ronnie and the description provided for the user is "Ronnie is from the Marketing Team"

You can see the below from the Active Directory Users and Computers.

Powershell - How to change AD user description field

Let us say that you want to change that to "Marketing Department User"

We would use a cmdlet called Set-ADUser to perform this action.

This is actually one of the cmdlets which has the ability to modify the largest number of attributes related to a user account in Active Directory.

Powershell - How to change AD user description field

So the command that will change the description is

Set-ADUser Ronnie -Description "Marketing Department User"

Powershell - How to change AD user description field

Yes it was as simple as that.

Now this doesn't make sense for a single account to do this from a Powershell window. You are better off using the Active Directory Users and Computers.

But imagine, you as an Administrator receive request to change 500 user descriptions and your manager just sent that in an excel sheet.

That is when Powershell comes into the picture to make your life simple.

Let us say that you modified the excel file that you received and converted to csv file in the below format.

Powershell - How to change AD user description field

The first column contains the SamAccountName and the second column you can have the updated description that needs to be applied.

So the way you would write the script will be as seen below.

Import-Module ActiveDirectory
$Users = Import-csv c:\Users.csv
foreach($User in $Users){
Set-ADUser $User.SamAccountName -Description $User.NewDescription
}

Save it as a .ps1 file and run from a Powershell window.

Boom! You just updated 500 User accounts details that easily.

I hope that this was informative and thank you for reading!

Share.

About Author

I am Adil Arif, working as a Senior Technical Support Engineer at Rubrik as well as an independent blogger and founder of Enterprise Daddy. In my current role, I am supporting infrastructure related to Windows and VMware datacenters.

7 Comments

  1. Import-Module ActiveDirectory
    $Users = Import-csv c:\test\test.csv
    foreach($User in $Users){
    Set-ADUser $User.SamAccountName -Description $User.Description
    }
    WAY THIS NOT WORKING

    • The script has a mis-spelling

      The .csv file has the names under SaAccountName
      The script is calling for SamAccountName

      Change one to match the other and it should work just fine.

    • Another issue is your script says this:

      Import-Module ActiveDirectory
      $Users = Import-csv c:\test\test.csv
      foreach($User in $Users){
      Set-ADUser $User.SamAccountName -Description $User.Description
      }

      Your Error is also here (Yours still says $Users, but this points tot he document and your Doc is test: not Users.) See Below:

      foreach($User in $test){

      Also (Depending on your CSV file, the heading for the column maybe wrong. If it was typed in your CSV as “Description” and not “NewDescription” then it is correct, but if it is the reverse then yours is incorrect) See example CSV in the above help blog.

      Set-ADUser $User.SamAccountName -Description $User.Description
      }

Leave A Reply