Change Network Location in Windows 8.1/2012 R2 from Powershell
Dan Salmon
August 26 2017
[windows]
Step 1
From an elevated PowerShell window issue the following command to gather some information about our current network profile:
Get-NetConnectionProfile
Name : Unidentified Network
InterfaceAlias : Ethernet
InterfaceIndex : 10
NetworkCategory : Public
IPv4Connectivity : LocalNetwork
IPv6Connectivity : LocalNetwork
The only information we really need from this output is the “InterfaceIndex”
Step 2
After getting the InterfaceIndex, we run the following command:
Set-NetConnectionProfile -InterfaceIndex 10 -NetworkCategory Private
The last argument is what category you want to switch it to. The only allowed values here are “Public” or “Private” as per the MSDN documentation. The category can also be “DomainAuthenticated” but Windows will automatically assign this when the machine is added to a domain.