Occasionally, after restarting the Hyper-V Server, the network profile is not set to DomainAuthenticated. This is the case when the restarted host starts the virtual machine which establishes a VPN connection to the domain controller and the server cannot contact Active Directory within the required time and the network profile is set to Private. This causes the rules that are set to the domain profile to simply not work and we cannot access the server services. The administrator must log in to remote server management and restart the NlaSvc service, which is responsible for setting the correct network profile.
If there is no other option, the following script added to the autostart should help us with this:
$NetworkProfiles = Get-NetConnectionProfile
Write-Host -ForegroundColor Yellow Network profiles: $NetworkProfiles.NetworkCategory
if($NetworkProfiles.NetworkCategory -ne "DomainAuthenticated"){
Write-Host -ForegroundColor Red No profile DomainAuthenticated. RESTART service NlaSvc
# Delay restart for 60s
Start-Sleep -s 60
# Restart service NlaSvc - checking network profile
Restart-Service -Name NlaSvc -Force
}
else{
Write-Host -ForegroundColor Green It's OK don't restart service NlaSvc
}