Update Active Directory Users in Bulk from CSV

PowerShell V2 script to update Active Directory users from a CSV file. Only specified fields in the CSV that are not missing update the users. The value "<delete>" flags to clear the attribute. Attributes are not updated if the value in the CSV matches the existing value in AD.

 
 
 
 
 
5 Star
(3)
724 times
Add to favorites
Active Directory
1/30/2017
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Modification for LDAP Attributes + Alternates
    1 Posts | Last post Wed 6:25 PM
    • Hey Richard,
      I am working on an integration that is to use a source of record that has basic employee information, but the database/exported CSV does not contain uniquely identifiable information that is also present on AD. I need to be able to match the users by first and last names that are active (possibly that are active(email?)), followed by adding/updating about 20 ldap attributes. I don't even believe I require the use of the 5 powershell fields. 
      
      Do I create the ldap fields at top of the file and as well as between lines 279-336? Are there additional modifications to this file aside from the block found in 241-359?
      
      Thanks
  • Run as another User
    1 Posts | Last post October 24, 2017
    • Hi,
      Sorry if very simple one but how can we run this script as different user?
  • CSV Set Up
    5 Posts | Last post October 12, 2017
    • I am testing the script just by trying to update the eMail Address of a user. 
      
      The scripts comes back with the failure:
      Field EmailAddress ist not in the csv file. 
      Script Aborted
      
      CSV file looks like this
      UserID,EmailAddress
      user.name,user@domain.com
      
      Now this is probably a misunderstanding on my site but... how do you expect the CSV to look like? 
      
      Thanks.
    • This also comes with the error message:
      
       $CsvFields = $Users | Get-Member -MemberType noteproperty | Select Na ...
      +                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : CloseError: (:) [Get-Member], InvalidOperationException
          + FullyQualifiedErrorId : NoObjectInGetMember,Microsoft.PowerShell.Commands.GetMemberCommand
    • Sorry for the delay. EmailAddress is the not LDAPDisplayName of an attribute of users, or one of the PowerShell properties supported by this script. The reason this property is not supported is because the EmailAddress property is simply a copy of the mail attribute of user objects. Instead of specifying the field "EmailAddress", use "mail" instead.
      I will do more testing when I get a chance, but I believe this accounts for your experience.
    • I do not get your error message when I use your csv file. The statement to populate $CsvFields works fine for me. But an error is raised later because EmailAddress is not recognized as the LDAPDisplayName of an attribute of users. It would work if the csv used the field name "mail" instead, and the array $Fields in the script defined the field "mail".
    • Hi, thanks for the answer. 
      
      I am wondering if I am doing something very obvious wrong, but I can´t get it working. 
      
      $Fields = @("mail")
      
      CSV = 
      UserID,mail
      user.name,user.name@domain.com
      
      Failure Message:
      Field mail is not in the CSV file
      Script Aborted.
      
      How does the CSV file has to look like for this to work? 
      
      Thanks a lot.
  • Facing issues | scipt is not updateing the attributes
    2 Posts | Last post April 27, 2017
    • 
      kindly check issues at https://social.technet.microsoft.com/Forums/windowsserver/en-US/c918b6d5-9998-4e2b-930a-7a270ef3a6ab/update-custom-and-other-attribute-of-user-in-ad-through-csv-file?forum=ADFS
      
    • In that thread you used $Update = $False when you ran the script, so it logged what the script would do, but did not actually update anything. I advised you to use $Update = $True and run the script again.