Windows: Change a LAN Interface Networkprofile to private

Hi

when the network profile of a Windows PC is set to public, there are firewall restrictions enabled which could prevent accessing the Computer from network. For example Windows Remoting.

Unfortunately in some cases the profile cannot be switch by the Network Gui(s) of windows.

Since Windows 8 this could be altered by a Powershell command let.

Determine your Network Interface

PS D:\> Get-NetConnectionProfile
Name             : Network
InterfaceAlias   : Ethernet0 2
InterfaceIndex   : 7
NetworkCategory  : Public
IPv4Connectivity : LocalNetwork
IPv6Connectivity : NoTraffic

Set the Profile for all interfaces to private

PS D:\> Set-NetConnectionProfile -NetworkCategory Private -Name *

For Windows 7 or Windows Server 2008 the network connection profile could be change by DCOM INetworkListManager Interface. The Category is defined constants 1=Private , 0=public, 2=Domain. This examples sets all interfaces with no internet connection and active to private.

PS D:\>$oNetworkListManager = [Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]"{DCB00C01-570F-4A9B-8D69-199FDBA5723B}"))
PS D:\>$aConnections = $oNetworkListManager.GetNetworkConnections()
PS D:\>$aConnections |Where-Object{-not $_.IsConnectedToInternet -and $_.IsConnected}|foreach{$_.GetNetwork().SetCategory(1)}

How Windows determines the network connection profile is explained in detail Technet
.

Michael

Leave a Reply Cancel reply