重命名计算机抛出 "access is denied" 错误,但我不知道是什么

Rename-Computer is throwing "access is denied" error but I can't figure out to what

我在托管 hyperv 机器的 Windows 10 Enterprise 机器上。我们称之为 "Win10Host"。 其中一个虚拟机是 "Win10Base",它是 Windows 10 Pro 的基本安装。

我正在尝试 运行 从 "Win10Host" 重命名 "Win10Base" 但它失败了(下面的错误)。

$secpasswd = ConvertTo-SecureString 'mypassword' -AsPlainText -Force
$localCreds = New-Object System.Management.Automation.PSCredential ('user', $secpasswd);

$computername = 'Win10Base';
$VMName = 'Win10BaseNew';
$VMIP = 'x.x.x.x';  //Redacted, I have used remote desktop to verify this ip is correct.

Rename-Computer -ComputerName $VMIP -LocalCredential $localCreds -NewName $VMName -Verbose;

Win10Base 是通过 windows 10 pro 安装的基本点击。 user 是安装后的初始用户设置。

起初是扔:

Rename-Computer : Cannot establish the WMI connection to the computer 'Win10Base' 
with the following error message: Access denied .
At line:9 char:1
+ Rename-Computer -ComputerName $computername -LocalCredential $localCr ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Win10Base:String) [Rename-Computer], InvalidOperationException
    + FullyQualifiedErrorId : RenameComputerException,Microsoft.PowerShell.Commands.RenameComputerCommand

在授予远程桌面权限、配置防火墙、在 dcomcnfg 中授予 "Windows Management Instrumentation" 权限并通过 wmimgmt.msc 授予对 CIMV2 命名空间的访问权限后,我到达了目前的情况。

目前 powershell 抛出:

Rename-Computer : Fail to rename computer 'Win10Base' to 'Win10BaseNew' 
due to the following exception: Access is denied.
At line:9 char:1
+ Rename-Computer -ComputerName $computername -LocalCredential $localCr ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Win10Base:String) [Rename-Computer], InvalidOperationException
    + FullyQualifiedErrorId : FailToRenameComputer,Microsoft.PowerShell.Commands.RenameComputerCommand

运行 场景:

在 Win10Base ISE 上 - 失败并显示 "access denied"。

在 Win10Base ISE 上 运行 作为管理员 - 成功。

在 Win10Host ISE 上 - 失败并显示 "access denied"

在 Win10Host ISE 运行 上作为管理员 - 失败并显示 "access denied"

据我所知,Win10Base 上的用户是管理员。我还启用了"god mode",看看能不能把用户类型改成高级,发现是administrators组。

正在检查 Windows 事件日志(应用程序、安全性、设置和系统)我看不到与当前访问被拒绝相关的任何内容。据我所知,DbView 中没有任何内容。

因此,我们将不胜感激任何关于下一步去哪里寻找什么访问被拒绝的建议。

如果计算机不在域中,则需要在凭据中指定您的用户域 - DOMAIN\user - 其中域是本地计算机名称。

还可以在远程计算机中使用 "winrm quickconfig" 在命令行

中启用 WinRM