【发布时间】:2023-04-08 12:19:01
【问题描述】:
我正在尝试远程运行 PowerShell 命令“move-vm”,但我遇到了似乎无法解决的权限错误。
我的 move-vm 命令如下所示:
move-vm -ComputerName SorceHost -Name $vm.name -DestinationHost $DestHost -IncludeStorage -DestinationStoragePath d:\vms -DestinationCredential $cred -Credential $cred
我正在定义这样的凭据
$username = ".\PSAPIUser"
$password = Get-Content 'C:\key\PSAPIAUTH.txt' | ConvertTo-SecureString
$cred = new-object -typename System.Management.Automation.PSCredential `
-argumentlist $username, $password
源和目标都在同一个AD域上,我专门为此功能创建了一个域管理员帐户。我已将域管理员组添加到源主机和目标主机上的本地组“Hyper-V 管理员”“管理员”。当我发出命令时,我得到:
move-vm : You do not have the required permission to complete this task. Contact the administrator of the authorization policy for the computer 'SourceHost'.
关于如何在 2012 年执行此操作的文章有很多,但据我了解,由于授权管理器的贬值,该流程在 2016 年发生了重大变化。
在 2016 年,是否有人对如何配置权限以允许使用 PowerShell 进行远程 Hyper-V 管理有任何经验?
提前致谢。
编辑:
$cred = Get-Credential
$cred
UserName Password
-------- --------
PSAPIuser@domain.net System.Security.SecureString
move-vm : You do not have the required permission to complete this task. Contact the administrator of the authorization policy for the computer
【问题讨论】:
-
我认为您没有使用将
$username定义为.\PSAPIUser所需的凭据。请改用域名。另外,文件C:\key\PSAPIAUTH.txt是否包含纯文本密码?尝试使用Get-Credential创建凭据时会发生什么 -
添加了上面的结果,还是不开心。我似乎在 Hyper-v 的远程 PowerShell 管理中找不到任何东西,特别是 2016 年。这很烦人
-
在黑暗中拍摄:有时,使用 UPN 作为用户名不起作用,而使用
domain\username格式则可以.. -
是的,试过了,还是不行
标签: powershell hyper-v windows-server-2016