Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

How to Open Firewall Ports in Windows using PowerShell

October 23, 2022
in Blog, Powershell
0
ADVERTISEMENT

Table of Contents

Windows Defender Firewall is a great feature in modern Windows versions. You may have an app (e.g., a local FTP server) which requires a port(s) to be open so other computers on your network can connect to it.

Open a port using netsh command

Note Note: You can run netsh command in Command Prompt (cmd) or Windows PowerShell.

1. Open an elevated Command Prompt or PowerShell window.

Pw1

2. Modify the appropriate values to match your app, e.g. the port number, the rule name, the protocol (TCP or UDP).

netsh advfirewall firewall add rule name="Rule Name" dir=in action=allow protocol=TCP localport=80,443

To delete the rule, execute the command as follows:

netsh advfirewall firewall delete rule name="Rule Name"

Open a port using PowerShell

PowerShell is an advanced form of command prompt. It is extended with a huge set of ready-to-use cmdlets and comes with the ability to use in scenarios. You can use it to open or close a port in Windows 10, 11.

There is a special cmdlet New-NetFirewallRule that can be used to open or block a network port in Windows 10, 11.

Open an elevated PowerShell window then run the following command to open tcp/3389.

New-NetFirewallRule `
    -DisplayName 'Rule Name' `
    -Profile 'Any' `
    -Direction Inbound -Action Allow `
    -Protocol TCP `
    -LocalPort 3389
PS C:\Windows\system32> New-NetFirewallRule -DisplayName 'Rule Name' -Profile 'Any' -Direction Inbound -Action Allow -Protocol TCP -LocalPort 6624

Name                          : {94a6669a-bbcf-47a7-b70a-bd6f0695a6a3}
DisplayName                   : Rule Name
Description                   :
DisplayGroup                  :
Group                         :
Enabled                       : True
Profile                       : Any
Platform                      : {}
Direction                     : Inbound
Action                        : Allow
EdgeTraversalPolicy           : Block
LooseSourceMapping            : False
LocalOnlyMapping              : False
Owner                         :
PrimaryStatus                 : OK
Status                        : The rule was parsed successfully from the store. (65536)
EnforcementStatus             : NotApplicable
PolicyStoreSource             : PersistentStore
PolicyStoreSourceType         : Local
RemoteDynamicKeywordAddresses :

You can see the firewall rule has been create in Windows Defender Firewall console.

Bg2181

To delete a firewall rule using PowerShell, execute the following command:

Remove-NetFirewallRule -DisplayName 'Rule Name' 
ADVERTISEMENT
5/5 - (1 vote)
Previous Post

The System Shutdown Cannot be Initiated Because Users Logged On

Next Post

How to Schedule Delete a Log File in Linux

Related Posts

Running Hyper-V and VMware Workstation on The Same Machine

August 15, 2024

How to Uninstall All Autodesk Products At Once Silently

July 29, 2024
Ftr5

How to Uninstall the Autodesk Genuine Service on Windows

July 29, 2024
Ftr19

How to Fix Windows Cannot Read the ProductKey From the Unattend Answer File in VirtualBox

July 26, 2024
Ftr25

How to Update Windows Terminal in Windows 10/11

July 26, 2024

How to Disable The Beep Sound in WSL Terminal on Windows

July 26, 2024

Leave a Reply Cancel reply

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

Recent Posts

  • How To Turn On uBlock Origin Extension in Chrome (2025)
  • Images Hidden Due To Mature Content Settings In CivitAI
  • Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2025 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory