The follow script yields True for firewall when " IsFireON = [boolean]$value -eq '0'" is set to 1 or 0.
#http://www.powershellpro.com/powershell-tutorial-introduction/powershell-scripting-with-wmi/
$serverList = ".\Servers.txt"
$outputCSV = ".\softwareInventory.csv"
$scriptpath = $MyInvocation.MyCommand.Path
$dir = Split-Path $scriptpath
pushd $dir
[System.Collections.ArrayList]$sysCollection = New-Object System.Collections.ArrayList($null)
foreach ($server in (Get-Content $serverList))
{
"Collecting information from $server"
$totCores = 0
$HKLM = 2147483650 #HKEY_LOCAL_MACHINE
$key = "System\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile"
$value = "EnableFirewall"
try
#http://blogs.technet.com/b/heyscriptingguy/archive/2010/03/11/hey-scripting-guy-march-11-2010.aspx
{
[string]$id = [Security.Principal.WindowsIdentity]::GetCurrent()
[wmi]$firewall = Get-wmiObject -list -Namespace "root\default" -ComputerName $server |where-object { $_.name -eq "StdRegProv" }
$si = @{
Server = [string]$server
FireSUPPORT = [string] $results = $firewall.GetDWORDValue( $HKLM, $key, $value)
IsFireON = [boolean]$value -eq '0'
}
$disks | foreach-object {$si."Drive$($_.Name -replace ':', '')"="$([string]([System.Math]::Round($_.Size/1gb,2))) GB"}
}
catch [Exception]
{
"Error communicating with $server, skipping to next"
$si = @{
Server = [string]$server
ErrorMessage = [string]$_.Exception.Message
ErrorItem = [string]$_.Exception.ItemName
}
Continue
}
finally
{
[void]$sysCollection.Add((New-Object PSObject -Property $si))
}
}
$sysCollection `
| select-object Server,Dev_Admins,IsFireON,FireWallOn,NotePadInstalled,Name,ErrorMessage,ErrorItem `
| sort -Property Server `
| Export-CSV -path $outputCSV -NoTypeInformation