Set Network Location to Private in Windows 8.1/Server 2012 R2

One of those annoyances that sometimes happen with the new Network Location in Windows 8.x is that the network gets mis-identified as Public when it should be Private, or the other way around. Changing this in the GUI is certainly possible, but annoying, so let's take advantage of the improved Windows PowerShell support in Windows 8.1 and do it quickly and easily. First, let's open up an elevated PowerShell window from our limited user session:
PSH> Start-Process WindowsPowerShell.exe -verb RunAs

Now, in that window, let's find out what our current network location is set to:
PSH> Get-NetConnectionProfile
...<snip>...
Name : Unidentified network
InterfaceAlias : vEthernet (Local-10)
InterfaceIndex : 18
NetworkCategory : Public
IPv4Connectivity : LocalNetwork
IPv6Connectivity : LocalNetwork

From this, we see that the problem interface has an Interface Index of 18, so:
PSH> Set-NetConnectionProfile  -InterfaceIndex 18 -NetworkCategory Private

And we're done.

11 Responses to Set Network Location to Private in Windows 8.1/Server 2012 R2

  • Harry says:

    Thank you very much,
    you helped me escape quickly from the noisy server room.

  • Bas says:

    Thanks, worked even when local group policy computer configuration would not do the trick. Despite the network access policy set to Private it remained at Public. Probably because the computer had been part of an Active Directory domain, but was removed from it uncleanly. Powershell to the rescue!

  • Moe says:

    Thanks, seems to work on a temporary basis in Windows Server 2012 R2 until a reboot. This is a DHCP server with a static IP on that card. How can I set it permanently in this scenario?

  • Feanor says:

    Charlie,
    Thanks for posting this. It worked like a charm for me and was persistent after a reboot. While I’m learning to embrace PowerShell I still like doing things in a GUI when possible. To that ends here’s a link to GUI approach for those interested.
    http://anonit.blogspot.com/2014/02/change-network-location-in-server-2012.html

  • Jens Glathe says:

    Hi Charlie,

    thank you, thank you, thank you. Now for that “annoying” part: What is needed to put some clue into those who package the GUI? “Annoying” does not begin to describe the inner rage I feel when I see this daftness of a user interface. “Annoying” sounds more like “a mere inconvenience”, and this is a few orders of magnitude off. I see you’re an MVP. So you’re on the MSFT campus, at least sometimes. Is there anybody to talk sense to?

    with best regards

    Jens

    • Charlie Russel says:

      Overall, I’m quite sure they’ve heard the issues with the new 8.x interface loud and clear. 8.1 was far better than 8.0 for those of us who use a command line. And the updates that have come out since 8.1 have taken it a step further. I expect the next version to address the concerns of the power user. Meanwhile, PowerShell just keeps getting better and better, so use it and love it.

  • Mark-Allen says:

    Very nice and fast. Many thanks. Mark-Allen.

  • Chris says:

    Thanks a million for this post – this worked for me when the GUI method didn’t.

  • Michael Yoo says:

    Whoa, thanks so much! This is so much easier than the GUI hell. It works!

  • manzoor says:

    Thanks man. You saved my day.

  • Charles Steiger says:

    New to PowerShell and Server 2012 R2 Datacenter Core mode in home lab. This aided me greatly! Thanks so much!

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>