Created
January 27, 2016 17:06
-
-
Save davegreen/5eabc188f78b2576c70e to your computer and use it in GitHub Desktop.
SCOM monitor script for checking firewall status. Requires something like the PowerShell script monitor MP by Wei Lim: https://gallery.technet.microsoft.com/Sample-Management-Pack-17b76379
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$API = New-Object -ComObject "MOM.ScriptAPI" -ErrorAction Stop | |
$PropertyBag = $API.CreatePropertyBag() | |
$Profiles = @{'Domain' = '0'; 'Standard' = '0'; 'Public' = '0'} | |
$Profiles.Domain = (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile' -Name EnableFirewall).EnableFirewall | |
$Profiles.Standard = (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile' -Name EnableFirewall).EnableFirewall | |
$Profiles.Public = (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\PublicProfile' -Name EnableFirewall).EnableFirewall | |
if ($Profiles.Values -contains 0) | |
{ | |
$PropertyBag.AddValue('State', 1) | |
$API.LogScriptEvent("FirewallState.ps1", 1009, 0, "One or more firewall profiles are disabled, see property bag for details.") | |
} | |
else | |
{ | |
$PropertyBag.AddValue('State', 0) | |
$API.LogScriptEvent("FirewallState.ps1", 1000, 0, "All firewall profiles are enabled.") | |
} | |
foreach ($key in $Profiles.Keys) | |
{ | |
$PropertyBag.AddValue($key, $($Profiles.Item($key))) | |
} | |
$PropertyBag |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment