Advertisement
PowerShell_PC_Aide

ForEach-Object (Get-NetFirewallRule).ps1

Aug 22nd, 2019
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2. ------------------------------------------------------------------------------------------
  3.     SRC: https://social.technet.microsoft.com/Forums/ie/en-US/3294e7c9-3b2b-408f-bca8-032f2b2fc33e/windows-firewall-rules?forum=winserverpowershell
  4.     O/P: https://imgur.com/as3wwCd
  5. ------------------------------------------------------------------------------------------
  6. #>
  7.  
  8. #Firewall
  9. $Firewall = Get-NetFirewallRule
  10.  
  11. #Condition
  12. $Condition = $Firewall | Where-Object {$_.Enabled -eq $true -and $_.Action -eq "Block"}
  13.  
  14. #Rule
  15. $Condition  |
  16.         ForEach-Object{
  17.         $Rule = $_
  18.         $_ | Get-NetFirewallPortFilter |
  19.             ForEach-Object{
  20.                 [pscustomobject]@{
  21.                     FQDN = "$env:computerName.$env:USERDNSDOMAIN"
  22.                     DisplayName = $Rule.DisplayName
  23.                     Name = $Rule.Name
  24.                    
  25.                    
  26.                 }
  27.             }
  28.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement