Updated Post: In version 1.2 of this script, there is no limitation that prevents you from setting the SamAccountName. And since the SamAccountName now becomes a modifiable attribute, to identify the existing user, you need to use the Identity in the csv header.
Eg: if you want to change the user who has the SamAccountName user01 to user001, then you need to put user01 under the Identity column and user001 under SamAccountName column in the csv file.
Happy New Year to you all !!
Here, I’d like to share the script that I have been working on for a few days. With this script, you can set any AD attribute of users from a csv text file. There are 3 parameters that you need to specify.
-File Path : Path of the csv file which contains the AD user attributes. This parameter is mandatory.
-OverwriteEmptyAttrib : This will determine whether the empty attributes found in the csv file will overwrite to existing AD users’ attribute or not. This parameter accepts $True or $False and it becomes mandatory if there are empty attributes defined in the csv file.
-RenameCN : This will rename the CN (Common Name) of the user if specified. This parameter is optional.
- You can include as many attributes as you can see in the attributes tab of the user. See Fig-3.
- Make sure you installed RSAT tool if you’re going to run the script on Windows Desktops. For Windows servers, you can install it by running the powershell command Install-WindowsFeature -Name “RSAT-AD-PowerShell”
- As this script is to modify the existing user attributes, SamAccountName is a mandatory value that you need to define in the csv file.
- For the manger attribute, you don’t need to specify the distinguished name of the manger but instead you can just put the SamAccountName of the manager.
- For the multi-value attributes (eg: postOfficeBox, proxyAddresses) , you need to write the values in @(‘value1′,’value2′,’value3’) which means an array in powershell. See Fig-2 for details.
You can find the script from the gist or at the end of this page.
You can download my script here.