Forum Discussion
Marvin Oco
Jan 11, 2021Steel Contributor
script on how to update AD user info data from csv file
any script on how to update AD user info data from csv file?
| UPN | First Name | Middle Name | Last Name | Title | Department | Company |
| anna@contoso.com | Anna | Santos | Luna | Vice Chairman | Office of the Chairman and President | Contoso Corp. |
| joy@contoso.com | Joy | Vera | Perez | Assistant | Loans Processing Center | Contoso Corp. |
3 Replies
- Marvin OcoSteel Contributor
will this work?
____________________
Import-Module ActiveDirectory
$csv = Import-Csv c:\users\user\Desktop\users.csv
foreach ($line in $csv) {
$UserPrincipalName = $line.UserPrincipalName
Get-ADUser -Filter {UserPrincipalName -eq $UserPrincipalName} |
Set-ADUser -Title $($csv.title) -Department $($csv.Department) -Company $($csv.company)
}
Write-Host "Done running Script"Read-Host -Prompt "Press Enter to exit"
_-----------------------------
You can ask for help writing PowerShell scripts over here in dedicated forum.
windows-server-powershell - Microsoft Q&A