locked
Update Active Directory user fields with powershell script RRS feed

  • Question

  • Hi all,

    I'm looking to mass update a field with new data in Active Directory for every user, rather than manually enter it one by one.  I'd like to do this by using Powershell scripts to import data from an excel sheet and then update the appropriate field with that data.  I've dabbled with Powershell before, but don't have much experience with it, so I'd appreciate it if somebody could point me in the right direction and get me started.

    EDIT: I'd also like to know how I could pull data out of fields in an Active Directory user with Powershell.
    • Edited by Blobbster Wednesday, June 26, 2013 8:13 PM
    Wednesday, June 26, 2013 8:02 PM

Answers

  • here is a good example, http://social.technet.microsoft.com/Forums/windowsserver/en-US/ca04cdce-472a-4d29-a3c5-91285dc2dcd8/importcsv-to-update-active-directory-users

    $USERS = Import-CSV c:\temp\users.csv
    $USERS|Foreach{
    Get-ADUser -filter {name -eq $_.name}|Set-ADUSer -TelephoneNumber $_.TelephoneNumber -MobilePhone $_.MobilePhone -StreetAddress $_.StreetAddress -City $_.City -Title $_.Title}

    $USERS = Import-CSV c:\temp\users.csv
    $USERS|Foreach{
    Set-ADUSer -Identity $_.samaccountname -TelephoneNumber $_.TelephoneNumber -MobilePhone $_.MobilePhone -StreetAddress $_.StreetAddress -City $_.City -Title $_.Title}


    2nd example is if you have sam accounts, and depending on your csv headings the $_.blah will change, gl
    • Edited by ImMax Wednesday, June 26, 2013 8:08 PM stuff
    • Proposed as answer by Yan Li_ Friday, June 28, 2013 5:21 AM
    • Marked as answer by Yan Li_ Monday, July 1, 2013 7:29 AM
    Wednesday, June 26, 2013 8:06 PM

All replies