Skip to content

Instantly share code, notes, and snippets.

@machv
Created February 15, 2014 14:07
Show Gist options
  • Save machv/9019731 to your computer and use it in GitHub Desktop.
Save machv/9019731 to your computer and use it in GitHub Desktop.
Set Public networks profile to private
$NLMType = [Type]::GetTypeFromCLSID(‘DCB00C01-570F-4A9B-8D69-199FDBA5723B’)
$INetworkListManager = [Activator]::CreateInstance($NLMType)
$NLM_ENUM_NETWORK_CONNECTED = 1
$NLM_NETWORK_CATEGORY_PUBLIC = 0x00
$NLM_NETWORK_CATEGORY_PRIVATE = 0x01
$INetworks = $INetworkListManager.GetNetworks($NLM_ENUM_NETWORK_CONNECTED)
foreach ($INetwork in $INetworks)
{
$Category = $INetwork.GetCategory()
if (!$INetwork.IsConnectedToInternet -and ($Category -eq $NLM_NETWORK_CATEGORY_PUBLIC))
{
$INetwork.SetCategory($NLM_NETWORK_CATEGORY_PRIVATE)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment