How to set all network adapters to private from batch or powershell?
How about this:
Get-NetConnectionProfile -InterfaceAlias "Network" | Set-NetConnectionProfile -NetworkCategory Private -Confirm:$false -PassThru
Usually (almost every time), where there's a Set-*
, there's a Get-*
. PowerShell cmdlets output Objects that can be chained (piped) to it's corresponding Verb-Noun
cmdlet.
-
Get-NetConnectionProfile
in this case, returns the connection profiles that have an interface name of "Network". -
Set-ConnectionProfile
. When piped to this cmdlet, you are able to grab the entirety of the object fromGet-NetConnectionProfile
, and modify it. I.e: setting it to Private.