What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Time variable will not display in PRTG advanced XML sensor

Votes:

0

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>”

microsoft-antimalware powershell prtg scep xml

Created on Nov 6, 2017 3:42:31 PM

Last change on Nov 7, 2017 6:31:05 AM by  Luciano Lingnau [Paessler]



1 Reply

Votes:

0

Hello there,
thank you for your KB-Post.

Please try the following instead:

"<Text>"
      write-host "Last definition update: $($time)"
"</Text>"

Does it work?

Created on Nov 7, 2017 6:32:25 AM by  Luciano Lingnau [Paessler]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.