Introduction

Windows categorizes network connections as public, private, or domain networks. Public networks are typically less secure, while private networks are trusted and allow more open communication. Using PowerShell, you can easily identify and change the network category of your connections to better suit your security needs.

Identifying the Firewall Profile

To identify the current firewall profile of your network connections, use the Get-NetConnectionProfile cmdlet:

Get-NetConnectionProfile

This command provides details about your network connections, including the name, interface alias, interface index, and network category. Here is an example output:

Name             : WBL
InterfaceAlias   : vEthernet (vLan)
InterfaceIndex   : 8
NetworkCategory  : Public
IPv4Connectivity : Internet
IPv6Connectivity : Internet

Changing the Firewall Profile

To change the network category of a specific connection from public to private, use the Set-NetConnectionProfile cmdlet. For example, to change the profile for the network named “WBL” to private, run the following command:

Set-NetConnectionProfile -Name "WBL" -NetworkCategory Private

Example Script

Here is a complete PowerShell script to list the current network profiles and change a specific profile from public to private:

# List all network connection profiles
Get-NetConnectionProfile

# Change the network category to Private for the specified profile
$profileName = "WBL"
Set-NetConnectionProfile -Name $profileName -NetworkCategory Private

# Confirm the change
Get-NetConnectionProfile | Where-Object { $_.Name -eq $profileName }

This script lists all current network profiles, changes the specified profile to private, and confirms the change by listing the updated profile details.


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.