Wednesday, November 29, 2017

How to connect to Remote Hyper-V in a workgroup network

We can access Hyper-V server and its machines through Hyper-V manager on a different machine if it is connected in Active Directory network.It will pickup the AD credentials we logged in with and provide access based on the rights the logged-in user have.
Prior to server 2016 and windows 10, we don’t have below option to connect with Remote Hyper-V.
1.PNG
So we don’t have option to use Hyper-V server on the previous OS of windows.
From the OS mentioned above (from windows 10), we can connect to remote Hyper-V server or client machines and access/control their VMs.
Before doing that, we need to configure some settings on the remote machine and on the local machine to create a trust between both the machines.
To do that, run below scripts on respective machines.
Server.ps1:
CommandLine : Set-ExecutionPolicy Unrestricted

CommandLine : Get-ExecutionPolicy

CommandLine : Start-Service WinRM

CommandLine : Enable-WSManCredSSP -Role "Server"

CommandLine : .\Configure-SMRemoting.exe -Enable

CommandLine : Set-NetFirewallRule -DisplayGroup 'Windows Management Instrumentation (WMI)' -Enabled true

CommandLine : Set-NetFirewallRule -DisplayGroup 'Windows Management Instrumentation (WMI)' -Enabled true -Passthru

CommandLine : Set-NetFirewallRule -DisplayGroup 'Windows Management Instrumentation (WMI)' -Enabled true -PassThru

CommandLine : Set-NetFirewallRule -DisplayGroup 'Remote Event Log Management' -Enabled true -PassThru

CommandLine : Set-NetFirewallRule -DisplayName 'File and Printer Sharing (Echo Request - ICMPv4-In)' -Enabled true 
              -PassThru

CommandLine : .\cscript.exe C:\Windows\System32\SCregEdit.wsf /AR 0

CommandLine : Set-NetFirewallRule -DisplayGroup 'Remote Volume Management' -Enabled true -PassThru

CommandLine : get-history | Format-List CommandLine | out-file c\server.txt
Client.ps1:
CommandLine : Enable-WSManCredSSP -Role "Client" -DelegateComputer "chellangi-2016"

CommandLine : Enable-WSManCredSSP -Role "Client" -DelegateComputer "chellangi-2016"

CommandLine : Connect-WSMan -ComputerName "chellangi-2016"

CommandLine : set-item wsman:\localhost\Client\TrustedHosts -value *

CommandLine : set-item wsman:\localhost\Client\TrustedHosts -value "chellangi-2016"

CommandLine : $current=(get-item WSMan:\localhost\Client\TrustedHosts).value

CommandLine : $current=(get-item WSMan:\localhost\Client\TrustedHosts).value

CommandLine : get-command *winrm*

CommandLine : get-command *remote*

CommandLine : get-command *winrm*

CommandLine : get-command *win*

CommandLine : get-command *remote*

CommandLine : winrm quickconfig

CommandLine : winrm quickconfig

CommandLine : clear

CommandLine : winrm quickconfig

CommandLine : winrm quickconfig

CommandLine : $Profile = Get-NetConnectionProfile -InterfaceAlias Ethernet1

CommandLine : Get-NetConnectionProfile 

CommandLine : $Profile = Get-NetConnectionProfile -InterfaceAlias ERWIN-AP01

CommandLine : $Profile = Get-NetConnectionProfile -InterfaceAlias "vEthernet (wifi)"

CommandLine : $Profile.NetworkCategory = "Private"

CommandLine : Set-NetConnectionProfile -InputObject $Profile

CommandLine : winrm quickconfig

CommandLine : winrm set winrm/config/client @{TrustedHosts="Name of the Server"}

CommandLine : winrm set winrm/config/client @{TrustedHosts="chellangi-2016"}

CommandLine : winrm set-winrm/config/client @{TrustedHosts="chellangi-2016"}

CommandLine : winrm set winrm/config/client @{TrustedHosts="chellangi-2016"}

CommandLine : winrm set winrm/config/client @{TrustedHosts="chellangi-2016"}

CommandLine : Enable-WSManCredSSP -Role "Client" -DelegateComputer "chellangi-2016"

CommandLine : Set-NetFirewallRule -DisplayGroup 'Remote Volume Management' -Enabled true -PassThru

CommandLine : get-history

CommandLine : get-history | format-list

CommandLine : get-history | format-list CommandLine

After that, add below settings on the local machine, to add remote machine to the trusted zone.
add to trusted.png

No comments:

Post a Comment