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:
1 | 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:
1 2 3 4 5 6 | 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:
1 | 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:
1 2 3 4 5 6 7 8 9 | # 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