在Hyper-v 2016中远程使用Move-VM所需的权限

问题描述 投票:0回答:1

我试图远程运行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
--------                                     --------
[email protected] 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
powershell hyper-v windows-server-2016
1个回答
-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/

© www.soinside.com 2019 - 2024. All rights reserved.