5

I'm trying to rename a workstation that was joined to our domain last week. It's been rebooted at least once since then.

My domain is based on Windows 2012 R2 and the members in question are running Windows 10 Pro. In case it's useful information I have three DCs (and, yes, they are synchronised).

The rename works most of the time:

$aa = Get-Credential administrator@contoso.com
Rename-Computer -ComputerName mynewpc -NewName alpc001 -DomainCredential $aa
WARNING: The changes will take effect after you restart the computer mynewpc.

But I have a couple of machines which stubbornly refuse to allow the rename:

Rename-Computer -ComputerName otherhp -NewName alpc005 -DomainCredential $aa
Rename-Computer : Fail to rename computer 'otherhp' to 'alpc005' due to the following exception: Cannot create a file when that file already exists.
At line:1 char:1
+ Rename-Computer -ComputerName otherhp -NewName alpc005 -DomainCredent ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (otherhp:String) [Rename-Computer], InvalidOperationException
    + FullyQualifiedErrorId : FailToRenameComputer,Microsoft.PowerShell.Commands.RenameComputerCommand

Here's another attempt:

netdom renamecomputer otherhp /newname:alpc005 /ud:contoso\administrator /pd:*
Type the password associated with the domain user:

This operation will rename the computer otherhp
to alpc005.

Certain services, such as the Certificate Authority, rely on a fixed machine
name. If any services of this type are running on otherhp,
then a computer name change would have an adverse impact.

Do you want to proceed (Y or N)?
y
Cannot create a file when that file already exists.

The command failed to complete successfully.

There is no computer (or other account) with this new name, and there's no entry in the AD DNS for it either.

The additional error report from $error[0] | fl -f as requested in a comment is as follows:

writeErrorStream      : True
Exception             : System.InvalidOperationException: Fail to rename computer 'otherhp' to 'alpc005' due to the following exception: Cannot create a file when that file already exists.
TargetObject          : otherhp
CategoryInfo          : OperationStopped: (otherhp:String) [Rename-Computer], InvalidOperationException
FullyQualifiedErrorId : FailToRenameComputer,Microsoft.PowerShell.Commands.RenameComputerCommand
ErrorDetails          :
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {0, 1}
PSMessageDetails      :

I don't have any IT support in the user's office, so we do as much as possible remotely. If all else fails I suppose I could grant enough privileges to the end user to unjoin their PC, rename it, and join it back again. But I really don't want to do that if there's a realistic alternative.

Suggestions gratefully received, thank you.


I've been asked for the output of NETDOM QUERY /Domain:{domain} WORKSTATION from each DC. The PC appears in the list for all three; here's a snippet from the results:

PS C:\Windows\system32> NETDOM QUERY /Domain:contoso.com /Server:DC1 WORKSTATION
List of workstations with accounts in the domain:

ALPC004      ( Workstation or Server )
...
OTHERHP
...

The PC in question (OTHERPC) does not have the ( Workstation or Server ) clause - but many of my PCs don't have this, either.

  • Do you have multiple DC's? Is this executing for a DC or from another workstation? Or is the rename occurring before domain joining? Could you please use advanced error capturing and return the result here? To capture an advanced error make the error message occur. Then run this code and copy the output $error[0] | fl -f – Colyn1337 Nov 15 '16 at 12:29
  • @Colyn1337 I have now clarified the question to state that by member I mean workstation and not DC. The join occurred last week and the rename has been attempted several times since then, including today. The workstation has been rebooted at least once since the first rename attempt, and at least once more since. I have updated the question to include this along with the output of the extended error message. Thanks. – roaima Nov 15 '16 at 12:46
  • Try removing the old computer object in AD and retry. You may need to reference the old computer by IP in your rename operation. – Colyn1337 Nov 15 '16 at 12:54
  • @Colyn1337 if I remove the object from AD won't that destroy my existing join? – roaima Nov 15 '16 at 12:55
  • 1
    @Colyn1337 in my test environment, deleting the AD object as you have recommended prevents the rename because it can't find the object to rename. – roaima Nov 15 '16 at 16:10
1

In the end what I ended up having to do to resolve the problem was this:

  1. Remote Desktop to the PC and remove it from the domain
  2. Before rebooting, switch off the firewall (or at least, to allow remote RDP from a non-domain private network)
  3. Reboot
  4. Rename the PC, and reboot again
  5. Join the PC back to the domain, and reboot once more

I notice that I still cannot re-rename this PC (same error), but at least it's got the right name now.

-1

Could your problem be linked to old data in Active Directory? Apparently there is an issue where when demoting an old Active Directory server some information will be left over.

How to remove data in Active Directory after an unsuccessful domain controller demotion

Have you tried renaming the host/client while one of the Active Directory servers are shut down? And then the other AD server?

External Trust - duplicate domain SIDs

Have you tried the -Force parameter for the Rename-Computer CMD-Let?

  • 1
    I'm not demoting a DC. This new computer name has never been previously used. – roaima Nov 15 '16 at 16:20
  • I'm not saying you are demoting a DC, but if you have demoted a DC in the past, then this can result in stale data. – hot2use Jan 30 '17 at 7:08
  • What stale data should I be looking for? I can understand that there may be stale data relating to the DC that has been demoted, but I fail to see the relevance of that to my problematic PC. Can you clarify, please? – roaima Jan 30 '17 at 11:04
  • Stale data is related to : It's stopped replicating because it believes its information could be stale, and to avoid problems related to lingering objects, it has stopped replication. – hot2use Jan 30 '17 at 12:40
  • All three of my DCs show replication is successful (repadmin /showrepl {servername}) – roaima Jan 31 '17 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.