Created
April 11, 2019 23:04
-
-
Save ArtisanByteCrafter/83f06aad5d7503fb0b9f2497fc064d5f to your computer and use it in GitHub Desktop.
PRTG sensor for Get-WBSummary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[Parameter(Mandatory = $true)] | |
[string] $Device, | |
[PSCredential] $Credential | |
) | |
$InvokeParams = @{ | |
Computername = $Device | |
ScriptBlock = { Get-WBSummary } | |
} | |
If ($Credential) { | |
$InvokeParams = @{ | |
Computername = $Device | |
ScriptBlock = { Get-WBSummary } | |
Credential = $Credential | |
} | |
} | |
Else { | |
$InvokeParams = @{ | |
Computername = $Device | |
ScriptBlock = { Get-WBSummary } | |
} | |
} | |
Try { | |
$BackupStatus = Invoke-Command @InvokeParams | |
$result = @" | |
{ | |
"prtg": { | |
"result": [ | |
{ | |
"channel": "BackupStatus", | |
"value": "0" | |
} | |
], | |
"text":"Last successful backup on $($BackupStatus.LastSuccessfulBackupTime)" | |
} | |
} | |
"@ | |
} | |
Catch { | |
$Result = @" | |
{ | |
"prtg": { | |
"error": "1", | |
"text": "Query not performed." | |
} | |
} | |
"@ | |
} | |
$Result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment