Greetings, I have a scenario where a command works in my test environment, but not in production.
This is the line: $path = (Get-AdUser $modelafter).distinguishedName.Split(‘,’,2)[1]
In the test environment it copies the distinguished name minus the modelafter’s username and the next line moves to the target OU without issue.
In production, the same command copies the entire distinguished name of the modelafter and gives an error on the next line when trying to move to the target.
The execution policy for both is unrestricted for current user.
The error message is:
Move-ADObject : The operation could not be performed because the object’s parent is either uninstantiated or deleted
At C:\Users\patellin\Desktop\New folder\Add_AD_User.ps1:102 char:44
- … DUser -Identity $TextBox_UName.Text | Move-ADObject -TargetPath $path
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : NotSpecified: (CN=Doe Jane,CN=Users,DC=bluelinx,DC=net:ADUser) [Move-ADObject], ADExcept
The version for the test environment:
PS C:\Windows\system32> $PSVersionTable
Name Value
PSVersion 5.1.17763.2931
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
BuildVersion 10.0.17763.2931
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Production:
PS C:\WINDOWS\system32> $PSVersionTable
Name Value
PSVersion 5.1.19041.1682
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
BuildVersion 10.0.19041.1682
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Thanks in advance