Wednesday, August 5, 2015

Change Window 8/10 Network Location using PowerShell

One thing that I am really annoyed by Windows 8 and then now Windows 10 is Set/Change network location.  Microsoft manages to make something so easy in Windows 7 to something that is so convoluted in new versions.

If you are comfortable with using commands, you may want to use PowerShell to change the Network Location instead.

1) You need to start PowerShell with elevated user account with command as below.
PSH>Start-Process WindowsPowerShell.exe -verb RunAs
Alternatively, you can type powershell in Search, and run it as an administrator by using the "Run As" option from the context menu (right click)

2) Use the Get-NetconnectionProfile to find out the InterfaceIndex of the connected NIC, e.g.
PSH> Get-NetConnectionProfile
......
Name : Unidentified network
InterfaceAlias : vEthernet (Local-10)
InterfaceIndex : 18
NetworkCategory : Public
IPv4Connectivity : LocalNetwork
IPv6Connectivity : LocalNetwork

3) Use the Set-NetConnectionProfile to change to the desired network location.
PSH> Set-NetConnectionProfile -InterfaceIndex 18 -NetworkCategory Private
That's it. This saves you from switching account, and then jump through hoops to get the network location changed.

(ref: http://blogs.msmvps.com/russel/2013/12/29/set-network-location-to-private-in-windows-8-1server-2012-r2/)

No comments: