I use a powershell script to rename hostname computer from our domain:
Rename-Computer -NewName $computername -DomainCredential $mycreds -Force -PassThru
Most of the time it works, but in a low % of the cases, after restarting the computer is out of domain.
The script also searches AD and makes sure that the new hostname isn't on AD.
What I've searched:
- c:\windows\debug\netsetup.log tells that everything is ok.
- The object exists on AD and well renamed (same OU)
- When this happens, if I try to log on to computer with an user domain, appears the error "The trust relationship between this workstation and the primary Domain failed"
Any idea of where is the error and how can I control it on future renames? Thanks