The following PowerShell script provides a way to change network profiles.

# Run as Administrator

# Get all network profiles set as public
$publicNetworks = Get-NetConnectionProfile | Where-Object { $_.NetworkCategory -eq "Public" }

if ($publicNetworks)
{
    foreach ($network in $publicNetworks)
    {
        try {
            Set-NetConnectionProfile -InterfaceIndex $network.InterfaceIndex -NetworkCategory Private
            Write-Host "Network $($network.Name) changed to Private."
        } catch {
            Write-Error "Failed to change network $($network.Name) to Private."
        }
    }
}

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.