Forum Discussion
ssstier
Dec 02, 2020Copper Contributor
Move and Rename Computer Object Despite Slow DC Syncronization
At my workplace, I configure properties of computer objects in my domain using PowerShell. Specifically, I change the name of a computer, then move it to its respective organizational unit. See...
NZScottie
Dec 12, 2020Copper Contributor
ssstier I have come across similar behaviour in a few of my scripts in multi domain controller environments with delayed replication timings around sites.
I found that I have to explicitly name the domain controller to which I am making the calls. This way I control the domain controller my powershell calls are being made against and know that when making subsequent queries the domain controller has the 'most up-to-date version' of the object (before full replication has taken place).
In your example, I would try getting the DC that the computer being renamed is communicating with and pass that through to the -server parameter in the Get-ADComputer command and see if that helps reduce the amount of strange behaviour you experience.
Hope this makes sense and helps set you in the right direction for having a more stable script.