Forum Discussion
Jesper Stein
Jun 07, 2017Brass Contributor
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 ...
- Jun 08, 2017
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]}
}
}
Manidurai Mohanamariappan
Jun 08, 2017Iron Contributor
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]}
}
}
Jesper Stein
Jun 08, 2017Brass Contributor
Worked great. Thanks for your help :)