我想授予非管理员用户启动/停止/检查特定虚拟机的权限。
Grant -VMConnectAccess cmdlet 应该可以完成这项工作。我还将该用户添加到“远程管理用户”组中。
但是当尝试连接到 VM 时,我在 Windows 事件日志中收到 .NET 异常:
Application: vmconnect.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: Microsoft.Management.Infrastructure.CimException
at Microsoft.Management.Infrastructure.Internal.Operations.CimSyncEnumeratorBase`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].MoveNext()
at System.Linq.Enumerable+WhereSelectEnumerableIterator`2[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].MoveNext()
at Microsoft.Virtualization.Client.Management.Server.LoadOSInfo()
at Microsoft.Virtualization.Client.ConnectionHelper.ConnectServer(Microsoft.Virtualization.Client.InformationDisplayer, System.String, Boolean, Microsoft.Virtualization.Client.Common.IUserPassCredential)
at Microsoft.Virtualization.Client.ConnectionHelper.TryGetVirtualMachinesInternal(System.String, Microsoft.Virtualization.Client.Common.WindowsCredential, Mode, System.String, System.Guid, Microsoft.Virtualization.Client.Management.IVMComputerSystem ByRef, System.Collections.Generic.List`1<System.String> ByRef, System.Exception ByRef)
at Microsoft.Virtualization.Client.ConnectionHelper.TryGetVirtualMachine(System.String, Microsoft.Virtualization.Client.Common.WindowsCredential, System.String, Microsoft.Virtualization.Client.Management.IVMComputerSystem ByRef, System.Exception ByRef)
at Microsoft.Virtualization.Client.InteractiveSession.CommandLineParser.TryParse(System.String[], Microsoft.Virtualization.Client.InteractiveSession.RdpConnectionInfo ByRef)
at Microsoft.Virtualization.Client.InteractiveSession.VmisApplicationContext.TryParseCommandLine(System.String[])
at Microsoft.Virtualization.Client.InteractiveSession.Program.Main(System.String[])
仅当我还将用户放入Hyper-V 管理员或管理员组时,vmconnect.exe 才起作用。但这使用户可以完全访问所有虚拟机。
更新:我想让它在 Microsoft Hyper-V Server 10.0.17763 Build 17763 上运行。但我也无法让它在 Microsoft Windows Server 2019 Standard 10.0.17763 Build 17763 上运行