Forum Discussion

Jesper Stein's avatar
Jesper Stein
Brass Contributor
Jun 07, 2017
Solved

How to copy one attribute to another

Hi   I need to move data from one attribute to another on a user object in Active Dirctory.   Today the attribute homePhone is porpulated with users private mobile number. I need to move this to ...
  • Hi
    Otherhomephone is multivalue attribute so that it is not working and you can try below script

    $users = get-aduser -Filter * -Properties *|Where-Object {$_.otherhomePhone -ne $null }| Select-Object Samaccountname,otherhomePhone

    foreach($user in $users)
    {

    if($user.otherhomePhone.count -gt 1)
    {

    foreach($hph in $user.otherhomePhone)
    {

    set-aduser -identity $user.Samaccountname -add @{otherMobile=$hph}
    }

    }
    else
    {
    set-aduser -identity $user.Samaccountname -add @{otherMobile=$user.otherhomePhone[0]}
    }
    }

     

Resources