PS Cmdlet Turns Win10 Networks Private
I just clean-installed Windows 10 1803 on one of my test machines. In that install’s wake, I found myself unable to RDP into that machine. “Oho!” I thought to myself “I bet the network is set Public, not Private.” Although my presumption was correct, I had trouble figuring out how to make that change in Settings. A quick visit to Google informed me that a command-line remedy could do the trick in PowerShell (PS). I immediately put it to work. Here’s what that looked like, as a PS cmdlet turns Win10 networks Private:
You need Get-NetConnectionProfile to see what’s up with your network profiles. This drives use of Set-NetConnectionProfile to make the appropriate profile Private.
[Click image to see full-sized view.]
How a PS Cmdlet Turns Win10 Networks Private
Because Win10 PCs can have multiple network profiles — think WiFi and Wired, plus one or more virtual switches for VMs — it’s important to target the right one when making the switch from Public to Private. That’s where Get-NetConnectionProfile comes into play. Use it to target the InterfaceIndex whose NetworkCategory value needs to change accordingly.
PowerShell cmdlets use a verb -noun stucture. The cmdlet’s name represents a verb, or action, that does something. Get-NetConnectionProfile is a verb that lacks a required noun. That’s because it looks stuff up that the system already knows. For Set-NetConnectionProfile, on the other hand, one value identifies a specific profile, and one or more others make changes to associated value(s).
Here’s more detail on Set-NetConnectionProfile syntax, using text from the preceding example. (If the following string breaks across multiple lines, it should appear as a single line in PowerShell):
Set-NetConnectionProfile -InterfaceIndex 17 -NetworkCategory Private
where
Set-NetConnectionProfile is the verb that indicates we’re going to set one or more values associated with a specific network profile.
-InterfaceIndex 17 identifies the specific network interface whose profile gets a value change. For this PC, the index is 17. It will vary on other machines, including yours.
-NetworkCategory Private assigns the NetworkCategory (Public/Private) the value “Public” for the designated interface index.
It’s pretty darn simple to do this, so worth getting to know.
But Wait: There’s IS a GUI Way to Do This, Too!
After a bit more poking around online, I did eventually find a way to make the necessary change in the GUI as well. By clicking Start → Settings → Network & Internet → Change connection properties, you get to a Settings page with a “Network profile” section at the top that includes radio buttons for Public and Private. It looks like this:
Settings does provide a path to this control, though it isn’t intuitively obvious (or wasn’t obvious to me, anyway).
Given how easy this is, why I did blog about the PS cmdlet alternative? Because I had trouble finding the GUI element myself, and because some people have reported being unable to access the Network profile control through the afore-mentioned sequence of interface clicks. In Windows, there are always multiple ways to get things done. This is one case where having another way can make the difference between completing a desired task, and leaving it undone. When it comes to using RDP with my battery of machines, the latter possibility is intolerable, so I *HAD* to find another way…