Listing Windows Firewall Rules Using Microsoft Power. Shell. At a customer site recently, I needed a way to list all the Enabled Windows Firewall Inbound Rules. I could not get what I needed by using the Windowsnetsh advfirewall monitor show firewall rule nameall dirincommand so I turned to using Power. Shell. I found the following article by James ONeill that helped me get started.
Introduction. Microsoft has created a new FTP service that has been completely rewritten for Windows Server 2008. This FTP service incorporates many new features. What I needed for a headstart was the following code from James article Function Get Fire. Wall. Rule. Param Name, Direction, Enabled, Protocol, profile, action, grouping. RulesNew object com. Object HNet. Cfg. Fw. Policy. 2. rules. If name rules rules where object. If direction rules rules where object. If Enabled rules rules where object. Enabled eq Enabled. If protocol rules rules where object. If profile rules rules where object. Profiles b. AND profile. If Action rules rules where object. Action eq Action. If Grouping rules rules where object. Grouping like Grouping. Get firewall. Rule enabled true sort direction,application. Name,name. format table wrap autosize property Name, LabelAction expressionFwaction. Direction expression fwdirection. LabelProtocol expressionFw. Protocols. protocol, local. Ports,applicationname. I created a script named listfw. I ran the script, I received the output shown in Figure 1. Figure 1. The last column wasnt formatted properly for me so I thought maybe the wrap parameter of Format Table was causing the issue. So I removed the wrap an reran the script. I received the output shown in Figure 2. Figure 2. OK, still not what I need. So I thought maybe the autosize was the culprit. I removed the autosize and reran the script. I received the output shown in Figure 3. Figure 3. OK, I am getting further away from what I really. What I want is a way for the Name column and the Application. Name column to be full width. Using get help format table full gave me a clue. The property parameter has some options available Name or Label lt string. Expression lt string or lt script block. Format. String lt string. Width lt int. 32. Alignment value can be Left, Center, or Right. I can see in James original code he is using the Label and Expression options. I just need to figure out how to use the Width option. After much trial and error, I came up with the following code spaces. Get firewall. Rule enabled true sort name. Name spaces. 1 expression. Action expressionFwaction. Direction expressionfwdirection. Protocol expressionFw. Protocols. protocol width8 ,. Local Ports expression. Ports width1. Application Name spaces. Running the script gives me the output shown in Figure 4. Figure 4. DOH So close. It seems the output is now limited by the width of the screen. Looking at the help for get table, I cannot see any option that allows me to make the table wider. That led me to finding this article. It appears the solution is very simple. Use out string width nnn. Using a width of 2. I get what is shown below. listfw. Name Action Direction Protocol Local Ports Application Name. Citrix ICA TCP In 1. Citrix IMA TCP In 2. Citrix MFCOM RPC RPC C Program Files x. Citrixsystem. 32mfcom. Citrix Print Service RPC RPC C Program Files x. Citrixsystem. 32Cp. Svc. exe. Citrix Remote MFCOM DLLs RPC RPC C WindowsSys. WOW6. 4dllhost. exe. Citrix Session Reliability TCP In 2. C Program Files x. CitrixXTEbinxte. Citrix SSL Relay TCP In 4. C Program Files x. CitrixXTEbinxte. Citrix WI Configuration Manager RPC RPC C Program Files x. CitrixSystem. 32Config. Mgr. Svr. exe. Citrix XML Relay TCP In 8. C Program Files x. CitrixSystem. 32ctxxmlss. Core Networking Destination Unreachable ICMPv. In System. Core Networking Destination Unreachable Fragmentation Needed ICMPv. In System. Core Networking DNS UDP Out C Windowssystem. Core Networking Dynamic Host Configuration Protocol DHCP In 6. C Windowssystem. Core Networking Dynamic Host Configuration Protocol DHCP Out 6. C Windowssystem. Core Networking Dynamic Host Configuration Protocol for IPv. DHCPV6 In 5. C Windowssystem. Core Networking Dynamic Host Configuration Protocol for IPv. DHCPV6 Out 5. C Windowssystem. Core Networking Group Policy LSASS Out C Windowssystem. Core Networking Group Policy NP Out System. Core Networking Group Policy TCP Out C Windowssystem. Core Networking Internet Group Management Protocol IGMP In System. Core Networking Internet Group Management Protocol IGMP Out System. Core Networking IPHTTPS TCP In IPHTTPS System. Core Networking IPHTTPS TCP Out C Windowssystem. Core Networking IPv. IPv. 6 In System. Core Networking IPv. IPv. 6 Out System. Core Networking Multicast Listener Done ICMPv. In System. Core Networking Multicast Listener Done ICMPv. Out. Core Networking Multicast Listener Query ICMPv. In System. Core Networking Multicast Listener Query ICMPv. Out. Core Networking Multicast Listener Report ICMPv. In System. Core Networking Multicast Listener Report ICMPv. Out. Core Networking Multicast Listener Report v. ICMPv. 6 In System. Core Networking Multicast Listener Report v. ICMPv. 6 Out. Core Networking Neighbor Discovery Advertisement ICMPv. In System. Core Networking Neighbor Discovery Advertisement ICMPv. Out. Core Networking Neighbor Discovery Solicitation ICMPv. In System. Core Networking Neighbor Discovery Solicitation ICMPv. Out. Core Networking Packet Too Big ICMPv. In System. Core Networking Packet Too Big ICMPv. Out. Core Networking Parameter Problem ICMPv. In System. Core Networking Parameter Problem ICMPv. Out. Core Networking Router Advertisement ICMPv. In System. Core Networking Router Advertisement ICMPv. Out. Core Networking Router Solicitation ICMPv. In System. Windows Firewall service does not start in Windows 1. Windows Firewall acts as the first layer of defense against malware, so it is always advisable to keep it turned ON unless you are using a third party firewall software. If for some unknown reason if you find your Windows Firewall does not start automatically at startup, then here are a few troubleshooting steps you may want to try out. The error messages you could receive are Windows Firewall is not the default firewall. Windows Firewall does not start. Windows could not start the Windows Firewall. First, scan your machine for malware using a good antivirus software. If you have installed a 3rd party firewall or a Security Suite, then that could also be the cause of the problem. Many times, third party security software can disable the Windows Firewall and even prevent it from starting up. Run System File Checker or sfc scannow. Next, type services. Windows Start Search and hit Enter to open up Services. Here ensure that the Windows Firewall Service is started and set on Automatic. You do this by clicking on the Start button. Also, ensure that the Remote Procedure Call Service the Base Filtering Engine Service is started and set on Automatic. Now you also have to ensure that the Windows Firewall Authorization Driver mdsdrv. To do so, type devmgmt. Device Manager. In the Views tab, check on Show Hidden Devices and also show Devices By Connection. Locate Windows Firewall Authorization Driver in the list and double click on it to open its Properties box. Click on Driver tab and ensure that the process is started, and the startup type is Demand. Click OK. Reboot. Hopefully, your Windows Firewall should be working OK now. If it does not help then run Group Policy Result Tool to check if there is a Firewall policy blocking it. Open an elevated command prompt window, type gpresult z and hit Enter. Check under Resultant Set Of Policies For Computer, esp under Security Options. Run the Windows Firewall Troubleshooter and see if it helps you. This ATS from Microsoft will help you repair and fix Windows Firewall problems automatically. See if it is available for your Windows or if it is built in. Reset Windows Firewall settings to defaults and see it that helps. Incidentally, drifting a bit away from the main topic, should you need to access the following panels easily, you can type the following Run commands and hit Enter. Firewall Settings Firewall. Settings. Firewall Control Panel Firewall. Control. Panel. Windows Firewall with Advanced Security wf. You might want to see this post if your Windows could not start the Windows Firewall on Local Computer. See this post if you receive Windows Firewall has blocked some features of this app message. How to Manage or Configure the Windows Firewall may also interest you.