Update AD users

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 5 years, 10 months ago.

  • Author
    Posts
  • #6266

    by nmuzic at 2013-01-30 06:19:39

    Could someone help me with updating users info in Active directory?
    I'm trying with following code:
    [code2=powershell]Import-Module ActiveDirectory
    $users = Import-Csv -Path c:\ADMIN\Users.csv -delimiter ";"
    foreach ($user in $users) {
    Set-ADUser -Identity $($user.SamAccountName) -Replace @{telephoneNumber = $($user.telephoneNumber); pager = $($user.Pager); ipPhone = $($user.ipPhone); facsimileTelephoneNumber = $($user.facsimileTelephoneNumber); mobile = $($user.mobile); physicalDeliveryOfficeName = $($user.physicalDeliveryOfficeName); department = $($user.department); description = $($user.description)}
    }[/code2]

    csv file contains user data in the format:
    samAccountName;givenName;sn;telephoneNumber;Pager;ipPhone;facsimileTelephoneNumber;mobile;physicalDeliveryOfficeName;department;description
    jondoe;jon;doe;+xxxxxxxx;xxxx;+xxxxxxxxxxx;+xxxxxxxxxxx;;place;IT department;IT officer
    I have problem with users that have an empty value for example "mobile" and doesn't update any value for that user.

    Regards,
    nmuzic

    by Tadziz at 2013-01-30 07:47:50

    hi,
    I'm new in powershell but maybe this link can help you
    http://blogs.technet.com/b/heyscripting ... ctory.aspx

    if you need to update users from your computer i would open new-pssesion and when update user using ad cmdlet 🙂

You must be logged in to reply to this topic.