I have a script that ends up creating a variable for each user in AD ($variableResult), iterating through each user. I have tested everything outputting to a log file - all fine. The last stage is to get it to write changes ($variableResult) to AD Attribute (POBox). It compares the 2 and if they are different it will overwrite.
This is the issue that I have:
Set-ADUser: Cannot bind parameter 'Identity'. Cannot convert value "CN=xxx,OU=Windows 10,OU=UserAccounts,OU=xxx,OU=xxx,DC=xxx,DC=xxx" to type "Microsoft.ActiveDirectory.Management.ADUser". Error: "Cannot convert the "CN=xxx,OU=Windows 10,OU=UserAccounts,OU=xxx,OU=xxx,DC=xxx,DC=net" value of type "Deserialized.Microsoft.ActiveDirectory.Management.ADUser" to type "Microsoft.ActiveDirectory.Management.ADUser"."
Here is what is stored in the variable:
PS > $variableResult
HQCSHOFF
I have modified the script to only search for my user name, set the POBox incorrectly in AD, so that the script should correct but instead i get this error:
if( $user.POBox -ne $variableResult ) {
set-aduser $user -Replace @{POBox="$variableResult"}
}