I would like to use this script to monitor the state of Antivrus on several computers, but it returns a string and prtg can't handle a string value in the "EXE/script" sensor! Is there another way to resolve this? This is the script i am using:
param($windowdomain,$windowsuser,$windowspassword,$computername) $secpasswd = ConvertTo-SecureString $windowspassword -AsPlainText -Force $mycreds = New-Object System.Management.Automation.PSCredential ("$($windowsdomain)\$($windowsuser)", $secpasswd) $AV = Get-WmiObject -ComputerName $computer -Credentials ($mycreds) -Namespace root\SecurityCenter2 -Class AntiVirusProduct switch ($AV.productState) { "262144" {$UpdateStatus = "Up to date" ;$RealTimeProtectionStatus = "Disabled"} "262160" {$UpdateStatus = "Out of date" ;$RealTimeProtectionStatus = "Disabled"} "266240" {$UpdateStatus = "Up to date" ;$RealTimeProtectionStatus = "Enabled"} "266256" {$UpdateStatus = "Out of date" ;$RealTimeProtectionStatus = "Enabled"} "393216" {$UpdateStatus = "Up to date" ;$RealTimeProtectionStatus = "Disabled"} "393232" {$UpdateStatus = "Out of date" ;$RealTimeProtectionStatus = "Disabled"} "393488" {$UpdateStatus = "Out of date" ;$RealTimeProtectionStatus = "Disabled"} "397312" {$UpdateStatus = "Up to date" ;$RealTimeProtectionStatus = "Enabled"} "397328" {$UpdateStatus = "Out of date" ;$RealTimeProtectionStatus = "Enabled"} "397584" {$UpdateStatus = "Out of date" ;$RealTimeProtectionStatus = "Enabled"} "397568" {$UpdateStatus = "Up to date"; $RealTimeProtectionStatus = "Enabled"} "393472" {$UpdateStatus = "Up to date" ;$RealTimeProtectionStatus = "Disabled"} default {$UpdateStatus = "Unknown" ;$RealTimeProtectionStatus = "Unknown"} } Write-Host ("0:" + $AV.displayname + " - " + $UpdateStatus + " - " + $RealTimeProtectionStatus)
Add comment