AD Account script error.


I have written the following script to migrate and update a few fields in an ad environment. The migration successfully completes, however, after renaming the object I will start getting errors. One error is that account is not found. common powershell error

(FullyQualifiedErrorId : ActiveDirectoryCmdlet:Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException,Microsoft.ActiveDirectory.Management.Commands.GetADUser)


From my understanding this info would be pulled from samaccountname and not the object name.

Also for sake of protection I have added the two variables at the top to justify server names. The relevant server when added do processes properly. Any help would be greatly appreciated. Thank you for your time.