Fix wrong NLA after reboot

This script will workaround the case when a server lost connection to the domain controller during a reboot (e.g. due to vpn services or wrong reboot sequence).

The server will stay on the PUBLIC network because the NLA service will only check once if it is connected to the domain network.
To workaround this add the script bellow to the task scheduler on computer startup.

REM Fnetonline
REM Mark de Bruin
REM http://tools.fnetonline.nl/script/006

REM The server will detect a Public network when there is no domain controller availible on startup
REM to force re-detection we restart the server.

Timeout 60

REM check the current profile and exit if it is correct
netsh advfirewall monitor show currentprofile|find “Domain Profile:”
if %errorlevel% == 0 exit /b 0
net stop NlaSvc
net start NlaSvc

REM now wait 5 minutes and check again
Timeout 300
netsh advfirewall monitor show currentprofile|find “Domain Profile:”
if %errorlevel% == 0 exit /b 0
REM second try

net stop NlaSvc
net start NlaSvc

REM wait a few seconds and check
timeout 20
netsh advfirewall monitor show currentprofile|find “Domain Profile:”

REM if it still isn’t correct exit with errorcode 99
if %errorlevel% == 1 exit /b 99
exit /b 0

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *