I've been having an issue with moving user accounts using PowerShell. I want to move specific users accounts from OU to OU based on what they have as an Office attribute.
The script is:
$prague = Get-ADUser -Filter * -Properties * | Select-Object -Property Office,SamAccountName | where -Property Office -eq "prague"
Move-ADObject -Identity $prague -TargetPath "OU=LAB,DC=test,DC=cz"
Powershell returns:
Move-ADObject : Cannot convert 'System.Object[]' to the type 'Microsoft.ActiveDirectory.Management.ADObject' required by parameter 'Identity'. Specified method is not supported. At line:6 char:25 + Move-ADObject -Identity $prague -TargetPath "OU=LAB,DC=test... + ~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Move-ADObject], ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.ActiveDirectory.Management.Commands.MoveADObject
Is it possible to run Move-ADObject cmdlet based on the Get-ADUser with plenty of parameters?