重命名 AD 计算机成员失败并显示“当该文件已存在时无法创建文件”

roa*_*ima 5 powershell active-directory

我正在尝试重命名上周加入我们域的工作站。从那以后它至少重新启动过一次。

我的域基于 Windows 2012 R2,有问题的成员正在运行 Windows 10 专业版。如果这是有用的信息,我有三个 DC(是的,它们是同步的)。

重命名大部分时间都有效:

$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.
Run Code Online (Sandbox Code Playgroud)

但是我有几台机器顽固地拒绝重命名:

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
Run Code Online (Sandbox Code Playgroud)

这是另一个尝试:

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.
Run Code Online (Sandbox Code Playgroud)

没有具有此新名称的计算机(或其他帐户),并且 AD DNS 中也没有相应的条目。

$error[0] | fl -f评论中要求的附加错误报告如下:

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      :
Run Code Online (Sandbox Code Playgroud)

我在用户办公室没有任何 IT 支持,所以我们尽可能远程进行。如果所有其他方法都失败了,我想我可以授予最终用户足够的权限以取消加入他们的 PC,重命名它,然后重新加入。但如果有现实的替代方案,我真的不想这样做。

收到建议,感激不尽。


我被要求提供NETDOM QUERY /Domain:{domain} WORKSTATION每个 DC的输出。PC 出现在所有三个列表中;这是结果的一个片段:

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
...
Run Code Online (Sandbox Code Playgroud)

有问题的个人电脑 ( OTHERPC) 没有该( Workstation or Server )条款 - 但我的许多个人电脑也没有这个条款。

roa*_*ima 1

最后我必须做的是解决这个问题:

  1. 远程桌面到 PC 并将其从域中删除
  2. 重新启动之前,关闭防火墙(或者至少允许来自非域专用网络的远程 RDP)
  3. 重启
  4. 重命名电脑,然后重新启动
  5. 将PC重新加入域,然后再次重新启动

我注意到我仍然无法重新命名这台电脑(同样的错误),但至少它现在有了正确的名称。