Set a Network to Private or Public (Set-NetConnectionProfile)
Change the firewall profile of a Wi-Fi or Ethernet connection from the terminal.
01Command
$ Get-NetConnectionProfile
Set-NetConnectionProfile -InterfaceIndex 12 -NetworkCategory Private02What it does
The Private profile allows file sharing and discovery; the Public profile blocks incoming connections and is what you want on hotel or café Wi-Fi. Get-NetConnectionProfile prints each active connection with its InterfaceIndex, which you feed into Set-NetConnectionProfile. The change applies instantly — no reboot needed.
03Risk
04Undo
$ Set-NetConnectionProfile -InterfaceIndex 12 -NetworkCategory Public05Sources
- Set-NetConnectionProfileEvidence: Documents the InterfaceIndex and NetworkCategory parameters used to move a connection between Public and Private profiles.
Last verified: 2026-09-18 · Category: Network
06Related solutions
A built-in PowerShell one-liner that answers 'is port 5432/3389/443 actually open through this network?' — no telnet client needed.
The PowerShell-native replacement for netstat: filter connections by state, port, or process and pipe results instead of parsing text.
The modern, scriptable replacement for nslookup: ask for exact record types, hit specific DNS servers, and see TTLs as objects.