Forum Discussion
sany98
May 07, 2021Copper Contributor
Move records from one attribute to another
Hi all, I need to move the records from employeeNumber field to the employeeID field. I would like to run test on one single user and then on whole OU. Is this doable and how? I'm still learning,...
- May 08, 2021
Yes, everything is doable in PowerShell
You will get ADUser with the employeeNumber and then set it to the employeeID$UserName="User1" Set-ADUser -id $UserName -Replace @{EmployeeID=(Get-ADUser $UserName -Properties employeenumber).EmployeeNumber}
sany98
May 11, 2021Copper Contributor
farismalaebHow do I Get-ADUser from specific OU? I've tried to use - SearchBase but it's throwing me an error. (Get-ADUser $UserName -Properties - SearchBase ''......)
SteveMacNZ
May 11, 2021Iron Contributor
- sany98May 12, 2021Copper Contributor
@SteveMacNZ
Sorry, it was a typo. There is no space between the - and SearchBase but the error is still there.Set-ADUser -id $UserName -Replace @{EmployeeID=(Get-ADUser $UserName -SearchBase 'OU=ex,OU=t2,DC=t3,DC=t4' -Properties employeenumber).EmployeeNumber}- SteveMacNZMay 12, 2021Iron Contributorcan you paste in the error message you are getting when you run the command
- sany98May 13, 2021Copper Contributor
Get-ADUser : A positional parameter cannot be found that accepts argument 'leoka'. At C:\Users\Administrator\Desktop\single_user.ps1:3 char:49 + ... EmployeeID=(Get-ADUser -Searchbase "OU=ex,OU=t2,DC=t3,DC=test" $Us ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Get-ADUser], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Management.Commands.GetADUser