Author Posts

February 10, 2016 at 9:19 am

Hello all,

I am trying to create a verification that reports $True is all of the Firewall Profiles are disabled or $False if any of they show as enabled.

Basically I run:

          $DisableFWProfiles = $Null
          $DisableFWProfiles = Get-NetFirewallProfile -Profile * | select-object name,enabled 

This will give me a result as such:

name Enabled
——— ————-
Domain False
Private True
Public False

What I am looking for is:
if all profiles return "Enabled = False" then to return $True
if any of the profiles return "Enabled = True" then to return $False

I tried this but it give me three $True/$False returns

          $DisableFWProfiles = $Null
          $DisableFWProfiles = Get-NetFirewallProfile -Profile * | select-object name,enabled 

          Foreach ($FWProfile in $DisableFWProfiles) {

            If ($FWProfile.Enabled -like "false") {$True}
			Else {$false}

All help is greatly appreciated.

February 10, 2016 at 9:31 am

If I've understood your question correctly this should give you what you want

$AllFWdisabled = $true

Get-NetFirewallProfile |
foreach {
if ($psitem.Enabled -eq 'True') {$AllFWdisabled = $false}

February 10, 2016 at 9:39 am

That did the trick.

Thank you very much.