2020-05-12

修正 Network Location Public / Private / Domain 的問題

經常發生 Domain Computer / Server 開機完畢後 Network Location 是 Public 造成 Firewall Profile 影響到連線的問題
因此寫了一個簡單的 Powershell Script 放在 GPO 讓電腦開機就去檢查一遍並進行修正
原理很簡單,先用 Get-NetConnectionProfile 查出目前的網路 Profile 是不是 Domain
如果不是 Domain 就 Restart Network Awareness Locaion 這個 Service

Start-Sleep 5
$ProfileOK = 0;
while ($ProfileOK -ne 1) {
$ProfileOK = 1;
$NALProfile = Get-NetConnectionProfile | select NetworkCategory
ForEach ($Profile in $NALProfile) {
if ($Profile.NetworkCategory -ne "DomainAuthenticated") {
$ProfileOK = 0;
Restart-Service NlaSvc -Force
break;
};
};
Start-Sleep 5
};
Start-Service NlaSvc

沒有留言:

張貼留言