New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


Powershell Script Problem - Backup Check

Votes:

0

Your Vote:

Up

Down

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

powershell script windows-server-backup

Created on Dec 20, 2018 9:46:02 AM by  Danny Robinson (10) 1



Best Answer

Accepted Answer

Votes:

0

Your Vote:

Up

Down

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

Created on Dec 20, 2018 2:50:17 PM by  Florian Rossmark (4,018) 3 2



3 Replies

Votes:

0

Your Vote:

Up

Down

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

Created on Dec 20, 2018 1:26:45 PM by  Andreas Günther [Paessler Support]



Votes:

0

Your Vote:

Up

Down

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

Created on Dec 20, 2018 1:30:23 PM by  Danny Robinson (10) 1



Accepted Answer

Votes:

0

Your Vote:

Up

Down

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

Created on Dec 20, 2018 2:50:17 PM by  Florian Rossmark (4,018) 3 2



Please log in or register to enter your reply.


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.