Set a Network to Private or Public (Set-NetConnectionProfile)

Change the firewall profile of a Wi-Fi or Ethernet connection from the terminal.

WindowsconfigurationnetworkpowershellLow risk
Find the interface with Get-NetConnectionProfile, then run Set-NetConnectionProfile -InterfaceIndex <n> -NetworkCategory Private.

01Command

Command
$ Get-NetConnectionProfile
Set-NetConnectionProfile -InterfaceIndex 12 -NetworkCategory Private

02What 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

RiskLow risk
!Warning: Never set a public hotspot network to Private — it opens your PC to discovery and file sharing by strangers on the same network.

04Undo

Undo
$ Set-NetConnectionProfile -InterfaceIndex 12 -NetworkCategory Public

05Sources

  • Set-NetConnectionProfile
    Microsoft Learn · vendor-doc · 2026-09-17
    Evidence: 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