Powershell 在Hyper-v 2016中远程使用移动虚拟机所需的权限
我试图远程运行PowerShell命令“move vm”,但我遇到了权限错误,似乎无法通过 我的move-vm命令如下所示:Powershell 在Hyper-v 2016中远程使用移动虚拟机所需的权限,powershell,hyper-v,windows-server-2016,Powershell,Hyper V,Windows Server 2016,我试图远程运行PowerShell命令“move vm”,但我遇到了权限错误,似乎无法通过 我的move-vm命令如下所示: move-vm -ComputerName SorceHost -Name $vm.name -DestinationHost $DestHost -IncludeStorage -DestinationStoragePath d:\vms -DestinationCredential $cred -Credential $cred Set-ADObject -Iden
move-vm -ComputerName SorceHost -Name $vm.name -DestinationHost $DestHost -IncludeStorage -DestinationStoragePath d:\vms -DestinationCredential $cred -Credential $cred
Set-ADObject -Identity $HostDeetsArra.Disname -ADD @{"msDS-AllowedToDelegateTo"="$service1/$Disname","$Service1/$HostName"}
#$disnam = distignushed name, $Service1 is the service 'cifs' $hostanme is the FQDN
我是这样定义凭证的
$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 administrators”“administrators”。当我发出命令时,我得到:
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管理方面有经验
提前谢谢
编辑:
远程管理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中,它将如下所示:
move-vm -ComputerName SorceHost -Name $vm.name -DestinationHost $DestHost -IncludeStorage -DestinationStoragePath d:\vms -DestinationCredential $cred -Credential $cred
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
我的信息来源如下
我认为您没有使用将
$username
定义为\PSAPIUser
所需的凭据。改用域名。此外,文件C:\key\PSAPIAUTH.txt
是否包含纯文本密码?。尝试使用Get Credential
创建凭据时发生的情况添加上述结果,但仍然没有乐趣。我似乎找不到任何关于Hyper-v远程PowerShell管理的信息,特别是2016年。这是一个非常令人烦恼的秘密:有时,当使用domain\username
格式时,使用UPN作为用户名是不起作用的。是的,试过了,但仍然没有任何效果。这是一个庞大的主题,在你开始改变事情之前,你需要完全理解它,本文将对此进行介绍。我可以剪切和粘贴,但这将是逐字逐句的,而且有潜在的危险。