简体   繁体   中英

Update Job Titles in AD via PowerShell

I have the following script to update the Users "Job Title" under the "Organization" of their Profile in AD

Import-CSV -Path C:\UsersTestv1.CSV | Foreach-Object {
#properties from the csv
$user  = $_.user
$title = $_.title
Get-ADUser -$user | Set-ADUser -Title "$title"
}

I am running this directly on the box to no avail

The CSV file im using test is set like this: user,title,test.user,Test Script, CSV File Snip

However, this is not updating the required field (I have over 400 users to update)

If i run the following: set-aduser "test.user" -Title "Example"

The required field successfully updates!

What am I doing wrong in my original script, I thought it should loop through each entry of the CSV and do the above :(

Any assistance is greatly appreciated

You could shorten your script a bit. As long as your csv contains the "user" and the "title" row, the users exist and you have the appropriate permissions, the script below should work:

Import-CSV -Path C:\UsersTestv1.CSV | Foreach-Object {
    Set-ADUser -Identity $_.user -Title $_.title
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM