【问题标题】:Permissions required to use Move-VM remotely in Hyper-v 2016在 Hyper-v 2016 中远程使用 Move-VM 所需的权限
【发布时间】: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


【解决方案1】:

远程管理 Hyper-V 使用一种称为约束委派的方法。想象一下场景。

您在主机 Man1 上,并且您正在向 Hyp-001 发出命令以将 VM 移动到 Hyp-002。因此,您让 Man1 向 Hyp-001 发出命令,这很好,因为它可以使用您的凭据,但是当 Hyp-001 将命令传递给 Hyp-002 时,它没有要传递的凭据,因此您会收到错误

move-vm : Virtual machine migration operation failed at migration source.
Failed to establish a connection with host 'ng2-vps-011.hyperslice.net': No credentials are available in the security package

要解决此问题,您需要授予特定权限,以允许主机在 AD 委派中相互运行特定服务。

从 PowerShell 看起来像这样:

Set-ADObject -Identity $HostDeetsArra.Disname -ADD @{"msDS-AllowedToDelegateTo"="$service1/$Disname","$Service1/$HostName"} 
#$disnam = distignushed name, $Service1 is the service 'cifs' $hostanme is the FQDN

2016 年你还需要这个:

Set-ADAccountControl -Identity $HostDeetsArra.Disname -TrustedToAuthForDelegation $true

我的信息来源如下

https://www.altaro.com/hyper-v/free-powershell-script-configure-constrained-delegation-hyper-v/

【讨论】:

  • 这是一个庞大的话题,您需要在开始更改之前完全理解,本文将涵盖所有内容。我可以剪切和粘贴,但它会是逐字逐句的,并且有潜在的危险。
猜你喜欢
  • 2022-06-10
  • 2018-07-18
  • 1970-01-01
  • 1970-01-01
  • 2012-05-29
  • 1970-01-01
  • 1970-01-01
  • 2019-03-28
  • 1970-01-01
相关资源
最近更新 更多