# Hyper-v server building note
###### tags: `實驗與紀錄`
Summary:
Remote control of hyper-v using Windows Server 2019 as server and win10 as client with assistant of RSAT
## Server side operation (in public network)
All operation are done after the installation of hyper-v manager
To enable the remote function
```powershell=
Enable-PSRemoting
```
While in public network,enable firewall rule of WinRM and CredSSP
```powershell=
Enable-WSManCredSSP -Role server
```
Set the trusted hosts
``` powershell=
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "WIN-82CDV4P065P"
```
CredSSP role setup
```powershell=
Enable-WSManCredSSP -Role client -DelegateComputer "WIN-82CDV4P065P"
```
Set the group policy
Computer Configuration > Administrative Templates > System > Credentials Delegation > Allow delegating fresh credentials with NTLM-only server authentication
```
Enable and add wsman/WIN-82CDV4P065P
```
# <font color="#f00">DONE!!</font>
## Server side operation (to setup in private network)
See if the connection is in private mode
```powershell=
Get-ConnectionProfile
```

If not, run this to change
```powershell=
Set-NetConnectionProfile -InterfaceAlias 乙太網路 -NetworkCategory Private
```
:::warning
If you didn't do this, might encounter error on configuration later on
:::
-------------------below are done on client (win10 pc)----------------------------
Add server to host
```powershell=
Add-Content -Path C:\Windows\System32\drivers\etc\hosts -Value "`n192.168.1.6`tWIN-82CDV4P065P"
```
Config the winRM
YES TO ALL OPTION
```powershell=
winrm quickconfig
```
Add server to trusted host
```powershell=
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "WIN-82CDV4P065P"
```
Config the policy
```powershell=
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\" -Name 'CredentialsDelegation'
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CredentialsDelegation\" -Name 'AllowFreshCredentialsWhenNTLMOnly' -PropertyType DWord -Value "00000001"
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CredentialsDelegation\" -Name 'ConcatenateDefaults_AllowFreshNTLMOnly' -PropertyType DWord -Value "00000001"
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CredentialsDelegation\" -Name 'AllowFreshCredentialsWhenNTLMOnly'
New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CredentialsDelegation\AllowFreshCredentialsWhenNTLMOnly\" -Name '1' -Value "wsman/WIN-8ET9IV6221H"
```
or use the gpedit like this
*(not my picture)*

### Problem I encountered

please note that I don't own this picture
:::info
## solution


:::
# <font color="#f00">DONE!!</font>
### <font color="33FFC2">And here is the finall result</font>

I haven't install any OS on it so....LOL
# <font color="4F33FF">Epilgue</font>
The Hyper-V remote control on Windows Server is now fully config and I don't need to access the server physically to operate :100:
Appendix
=======
tips for remote desktop
(you will need to install the Windows function first for sure)
```powershell=
netsh.exe advfirewall firewall add rule name="ICMP ECHO REQUEST" dir=in action=allow protocol=icmpv4
```
this allows you to ping your host