Invalid network profile after restarting Hyper-V Server

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
     } 
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments