0

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

Deitools
  • 101

1 Answers1

1

Never rename hostname after joining a client to domain. Either rename it before joining the domain or let the name 'as is'. Because it is security issue. According to Microsoft's knowledge base article, it is recommended to disjoin client from domain and rejoin it, but I found article which suggests not disjoin client after joining to domain.

Sairam
  • 46
  • 1