I am using the following code to monitor when SCEP (Microsoft Antimalware) definitions are updated. For some reason, the output in powershell returns "Last definition update: 11/5/2017 1:18:12 PM" but in PRTG it just returns "Last definition update:". Is there any way I can get this code to return the date in PRTG? . . .
$data = Get-ItemProperty "HKLM:\Software\Microsoft\Microsoft Antimalware\Signature Updates" | Select-Object -ExpandProperty SignaturesLastUpdated
$time = [DateTime]::FromFileTime( (((((($data[7]*256 + $data[6])*256 + $data[5])*256 + $data[4])*256 + $data[3])*256 + $data[2])*256 + $data[1])*256 + $data[0])
$2daysago = (get-date).AddDays(-2)
$3daysago = (get-date).AddDays(-3)
if ($time -lt $2daysago){
$warninglevel = 0
}
if ($time -gt $2daysago){
$warninglevel = 1
}
if ($time -gt $3daysago){
$warninglevel = 2
}
"<prtg>"
"<Text>"
write-host "Last definition update:" -NoNewLine $time
"</Text>"
" <result>"
“ <channel>DefinitionStatus</channel>”
“ <value>$warninglevel</value>”
“ <LimitMaxError>2</LimitMaxError>”
“ <LimitMode>1</LimitMode>”
“ </result>”
“</prtg>”
Hello there,
thank you for your KB-Post.
Please try the following instead:
"<Text>" write-host "Last definition update: $($time)" "</Text>"Does it work?
Nov, 2017 - Permalink