Hi All,

Wonder if anyone who is good with powershell help.

I have written a very basic backup check script that i thought was working great. However it seems to give me false positive and i think i know why. However when i make the change which is only putting speech marks around the interger it will work one day and i have to revert it for it to work another.

The script checks "lastbackupresulthr" value which is always 0 if successful and a silly number if not

$errorcode = Get-WBSummary | Select-Object lastbackupresulthr

$status = if($errorcode = "0"){ return "0:Sucess" }else{ return "1:Failed" exit 0 }

"<prtg>" "<result>" "<channel>" "BackupStatus" "</channel>" "<value>" echo $status "</value>" "</result>" "</prtg>"


Article Comments

Hi Danny,

Thank you for your post.

Please let me know how exactly does the false positiv show up? What is the sensor showing?

Thank you!


Kind regards,
Andreas Günther
Tech Support, Paessler AG


Dec, 2018 - Permalink

Hi Andreas,

Thanks for your reply.

Its giving the opposite result so when it's failed it's showing success and when successful it's showing failed. However when i remove or add the speech marks around "0" i get the right result. Which is great however it seems to revert the other way round another day.

I am seeing this on many servers with different versions of PS. Is there a better way i can pipe the integer.

Thanks


Dec, 2018 - Permalink

Danny,

Can you post two results for this line - of those alternating dates?

$errorcode = Get-WBSummary | Select-Object lastbackupresulthr

I am curios of what is in your $errorcode variable.

This sounds all like you are using the internal Windows backup.

Interesting would also be the output of two days for this command:

Get-WBSummary |fl

There is another flaw - of what I checked - there is more to the command it self - you should also check for when the last backup occurred and actually calculate something like a date-difference out of it to determine if the backup is current at all - but that would be a second step.

Don't have a Windows-Backup environment at hand - so I can't test it out..

Regards

Florian Rossmark

www.it-admins.com


Dec, 2018 - Permalink