如何通过 Windows 10 远程管理 Hyper-V 2016 独立版?

mon*_*ner 7 hyper-v hypervisor hyper-v-server-2016

如何通过我的 Windows 10 笔记本电脑连接到我的 Hyper-V 2016 独立版?

背景:我将其设置为家庭实验室。我遵循 一些 指南,但我还没有找到似乎适用于 Hyper-V 2016 免费版的指南/Youtube 教程。这是 Hyper-V 独立版的“hello world”,我不能t 找到适用于 2016 年的指南。(Hyper-V 2012 + Windows 8 似乎有一些解决问题的自动化脚本,但不适用于 Hyper-V 2016。)

语境

  • 服务器:Hyper-V server 2016(免费,独立),fqdn:server.local,
  • 客户端:Windows 10 专业版
  • 补充说明
    • 客户端的 etc/hosts 文件包含服务器 fqdn 的条目
    • 客户端或服务器都不在工作组或域中
  • 我的目标:使用客户端的 Hyper-V 管理器远程管理服务器

错误

An error occurred while attempting to connect to server "server.local". Check that the 
Virtual Machine Management service is running and that you are authorized to
connect to the server. 

Hyper-V encountered an error trying to access an object on computer 'server.local' because 
the object was not found. The object might have been deleted. Verify that the Virtual 
Machine Management service on the computer is running.
Run Code Online (Sandbox Code Playgroud)

我在服务器上做了什么

# sconfig.cmd: Enable "Configure Remote Management"
# sconfig.cmd: Add Local Administrator
# sconfig.cmd: Enabled Remote Desktop
Enable-PSRemoting
Enable-WSManCredSSP -Role server
sc start vmms                                  # Is this the "missing object"?
netsh advfirewall set currentprofile state off # Let's try disabling firewall
Run Code Online (Sandbox Code Playgroud)

我在客户端做了什么

Set-Item WSMan:\localhost\Client\TrustedHosts -Value "server.local"
Enable-WSManCredSSP -Role client -DelegateComputer "server.local"
# Changed group policy: "Computer Configuration > Administrative Templates > System > Credentials Delegation > Allow delegating fresh credentials with NTLM-only server authentication" by doing: "Click Enable and add wsman/fqdn-of-hyper-v-host."
# Disabled firewall
# dcomcnfg > COM SECURITY > Access Permissions > Edit Limits > Anonymous Login > ALLOW Remote Access
cmdkey /add:YOURSERVERNAME /user:USERNAMEONTHESERVER /pass:THEPASSWORDOFTHATUSER
Run Code Online (Sandbox Code Playgroud)

我如何触发错误

在客户端:

  1. 启动“连接到服务器”
    1. 尝试一次:“将‘另一台计算机:’设置为‘192.168.10.2’”
    2. 尝试二:“将‘另一台计算机:’设置为‘server.local’”
  2. 点击“确定”
  3. (错误:“尝试连接到服务器 'server.local' 时发生错误...)

mon*_*ner 21

发现我的具体问题:) 我使用了无效的主机名,并且 DNS 解析不正确。

  • 错误:server-1.local
  • 右:server-1-local

但另一方面,我还发现 Microsoft 文档(使用 Hyper-V 管理器远程管理 Hyper-V 主机)没有记录我使事情正常运行所需的所有说明。大体上是正确的,但少了一步。所以我附上了我的手动设置说明。

有关通过 Windows 10 Professional 远程管理 Hyper-V 2016 的完整设置说明,请参见下文。我的设置涉及两台独立的物理机器 - 我从头开始安装两个系统。

在 Hyper-V 服务器上

  1. 安装Hyper-V Server 2016(通过 GUI)
  2. 设置密码注意:在终端gui运行中更改以下内容 sconfig
  3. 设置计算机名称(例如 server-1);注意:不要使用句号
  4. 配置远程管理(禁用 => 启用)
  5. 远程桌面(禁用 => 启用)
  6. 在 Powershell 窗口中,以管理员身份运行:

Powershell 命令:

Enable-PSRemoting
Enable-WSManCredSSP -Role server
Run Code Online (Sandbox Code Playgroud)

在台式机/笔记本电脑上,您将远程管理 Hyper-V

  1. 安装 Windows 10 Professional/您的驱动程序/您的应用程序 (GUI)
  2. 更改网络适配器设置
    • 如果使用较旧的 Windows 10 补丁
      • 单击开始 > 搜索“家庭组”> 启动“家庭组”
      • 单击链接以更改网络类型(公共 => 私有)
    • 如果使用较新的 Windows 10 补丁
      • 试试这个:转到“开始菜单>(键入)'以太网'>(单击)以太网适配器>(单击)私有”
  3. 在您的主机文件中添加一个 DNS 条目(以管理员身份运行记事本)
    • 编辑“C:\Windows\System32\drivers\etc\hosts”
    • 添加像“192.168.100.2 server-1”这样的条目
  4. 在 Powershell 窗口中,以管理员身份运行:

Powershell 命令:

Enable-PSRemoting
Set-Item WSMan:\localhost\Client\TrustedHosts -Value server-1
Enable-WSManCredSSP -Role client -DelegateComputer server-1
Enable-WindowsOptionalFeature -Online -FeatureName:Microsoft-Hyper-V -All
cmdkey /add:server-1 /user:Administrator /pass
Run Code Online (Sandbox Code Playgroud)

笔记

Microsoft 官方文档缺少cmdkey指令,该指令注册进入 Hyper-V 服务器所需的登录信息。我在一个单独的文档中找到了它。

  • 这很好,正如指出的那样,官方文档缺少 `cmdkey` 命令,它确实是 _key_,哈哈。我还发现,只要网络配置文件是私有的,就可以在服务器上不使用 `Enable-WSManCredSSP -Role server` 命令的情况下工作。 (2认同)