Powershell make all networks private

Get-NetConnectionProfile | Set-NetConnectionProfile -NetworkCategory Private

One liner - change network from public to private:

Set-NetConnectionProfile -InterfaceIndex (Get-NetConnectionProfile | Where-Object IPv4Connectivity -eq 'Internet' | Select-Object -First 1 -ExpandProperty InterfaceIndex) -NetworkCategory Private
PS C:\Windows\system32> Get-NetConnectionProfile

Name             : Unidentified network
InterfaceAlias   : VirtualBox Host-Only Network #2
InterfaceIndex   : 10
NetworkCategory  : Public
IPv4Connectivity : NoTraffic
IPv6Connectivity : NoTraffic

Name             : Unidentified network
InterfaceAlias   : VirtualBox Host-Only Network
InterfaceIndex   : 7
NetworkCategory  : Public
IPv4Connectivity : NoTraffic
IPv6Connectivity : NoTraffic

Name             : Network
InterfaceAlias   : Ethernet
InterfaceIndex   : 3
NetworkCategory  : Private
IPv4Connectivity : Internet
IPv6Connectivity : LocalNetwork


PS C:\Windows\system32> Set-NetConnectionProfile -InterfaceIndex 7,10 -NetworkCategory Private