Search code examples
windowspowershellregistryicmp

Use registry to see ICMP type settings


I would like to see which ICMP types are allowed / enabled on my system.

I've found this where you can set up your ICMP but is there a possibility to see these settings in registry or to get them through powershell commands?


Solution

  • Use Get-NetFirewallRule to enumerate the firewall rules. Use Get-NetFirewallPortFilter to get details about what these rules are filtering. Filter the output for ICMP protocol rules, then select the ICMP type.

    Get-NetFirewallRule -Enabled True -Action Allow |
        Get-NetFirewallPortFilter |
        Where-Object { $_.Protocol -in 'icmpv4', 'icmpv6' } |
        Select-Object -Expand IcmpType -Unique
    

    Replace Allow with Block to enumerate blocking rules.

    If Get-NetFirewallRule can't find a rule it will throw an error. You can suppress that by adding -ErrorAction SilentlyContinue to the command.

    Note that the *-NetFirewall* cmdlets were introduced with Windows Server 2012 and are not available in earlier versions. For those you need to work with the netsh command. Use something like this to enumerate firewall rules

    netsh advfirewall firewall show rule all
    

    and parse the output for the relevant information.