Forum Discussion

Marvin Oco's avatar
Marvin Oco
Steel Contributor
Jan 11, 2021

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?

 

UPNFirst NameMiddle NameLast NameTitleDepartmentCompany
anna@contoso.comAnnaSantosLunaVice ChairmanOffice of the Chairman and PresidentContoso Corp.
joy@contoso.comJoyVeraPerezAssistantLoans Processing CenterContoso Corp.

3 Replies

  • Marvin Oco's avatar
    Marvin Oco
    Steel 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"

     

     

    _-----------------------------