. "$PSScriptRoot\_common.ps1" Section 'network-set-private' { $profiles = Get-NetConnectionProfile -ErrorAction SilentlyContinue if (-not $profiles) { Log 'No active NetConnectionProfile (offline?) - nothing to set' return } foreach ($p in $profiles) { Log ("Profile {0} (idx {1}) was {2}" -f $p.Name, $p.InterfaceIndex, $p.NetworkCategory) if ($p.NetworkCategory -ne 'Private') { Set-NetConnectionProfile -InterfaceIndex $p.InterfaceIndex -NetworkCategory Private Log (" -> set to Private") } else { Log ' already Private' } } }