Skip to content

Instantly share code, notes, and snippets.

@florianbeisel
Created November 10, 2011 16:18
Show Gist options
  • Save florianbeisel/1355266 to your computer and use it in GitHub Desktop.
Save florianbeisel/1355266 to your computer and use it in GitHub Desktop.
Changing the Network Category to Private
@echo off
powershell -ExecutionPolicy unrestricted -scope CurrentUser .\setNetworkCategoryToPrivate.ps1
@echo off
REM Schedules the Powershell Script to run every boot. Eventually this should be changed to "BEIANMELDUNG", this is done by changing the /SC Parameter.
REM Eventually this script should be run as administrator or at least it should be made sure, that the /RU and /RP Parameter are being set according to the system.
SCHTASKS /Create /TN AutomaticNetworkCategory /TR "powershell -ExecutionPolicy unrestricted -scope CurrentUser .\setNetworkCategoryToPrivate.ps1" /SC BEIMSTART
$nwcon = [Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]"{DCB00C01-570F-4A9B-8D69-199FDBA5723B}")).getNetworkConnections()
$res = $nwcon | % {
$_.GetNetwork().SetCategory(1)
}
# More unreadable (but tested form)
# [Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]"{DCB00C01-570F-4A9B-8D69-199FDBA5723B}")).getNetworkConnections() | % {$_.GetNetwork().SetCategory(1)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment