Home > Software design >  Copy extensionAttribute2 from one user on AD to another user using powershell
Copy extensionAttribute2 from one user on AD to another user using powershell

Time:10-06

I would like to copy a user's extensionAttribute2 value to another user on AD using powershell. For example if Joe Bloggs has ABC set as his extensionAttribute2, I would like to copy this and give John Smith the extensionAttribute2 value of ABC.

I created this but it doesn't seem to work:

Get-ADuser -Identity "Joe.Bloggs" -Properties extensionAttribute2 | Select-Object -ExpandProperty extensionAttribute2 | -Add extensionAttribute2 -Members "John.Smith" -PassThru | Select-Object -Property SamAccountfullname

I am new to powershell, any help would be appreciated. Thanks

CodePudding user response:

Use Set-ADUser to update the target user:

Set-ADUser -Identity John.Smith -Replace @{extensionAttribute2 = Get-ADuser -Identity "Joe.Bloggs" -Properties extensionAttribute2 |Select-Object -ExpandProperty extensionAttribute2}
  • Related