Hi All, in this post I am going to share information on how can you
update an attribute(s) in AD for multiple objects. In this post, I am using a
CSV file that contains users’ First Name, Last Name, their login name and
Employee ID. I wanted to update Employee ID for all the users listed in CSV
file.
To achieve this, I have complied a PowerShell script that uses CSV file
and update AD attributes for multiple users.
CSV file: I saved CSV file in C:\ADTest.CSV.
I ran following PowerShell script as admin. This script import CSV data,
updates EmployeeID data for each login name (sAMAccountName) listed in CSV
file.
#Import Active Directory module
Import-Module ActiveDirectory
#Import CSV file
$Obj=Import-Csv "C:\ADTest.csv"
foreach($Usr
in $Obj)
{
Get-ADUser -Filter
"sAMAccountName -eq '$($u.sAMAccountName)'" -properties
* | set-aduser -replace
@{employeeID="$($u.employeeID)"} -PassThru
}
I hope you find this useful.
Comments
Post a Comment