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

Script returning a string value

Votes:

0

I am writing a script which will return the last sync code and the last successful sync date so that I can monitor my SCCM's server ability to keep itself up to date with Microsoft's update catalog.

Import-Module (Join-Path $(Split-Path $env:SMS_ADMIN_UI_PATH) ConfigurationManager.psd1)

$SiteCode = Get-PSDrive -PSProvider CMSITE
Set-Location -Path "$($SiteCode.Name):\"

$syncResult = get-cmsoftwareupdatesyncstatus

$xmlOutput = '<?xml version="1.0" encoding="UTF-8" ?><prtg>'

$xmlOutput = $xmlOutput + "<result>
<channel>Sync Code</channel>
<value>" + $syncResult.lastSyncErrorCode + "</value>
<unit>Absolute</unit>
<limitmode>1</limitmode>
<LimitMaxError>0</LimitMaxError>
<LimitErrorMsg>SCCM Error: Sync with Microsoft Update Catalog failed.  Code: %value</LimitErrorMsg>
</result>
<result>
<channel>Last Successful Sync Time</channel>
<value>" + $syncResult.lastSuccessfulSyncTime + "</value>
<unit>float</unit>
</result>"

$xmlOutput = $xmlOutput + "</prtg>"
$xmlOutput

The idea is that if an error occurs, I can tell how long it has been a problem by having the last successful sync returned right next to it. How can I have PRTG display text in a channel? I keep getting Custom SNMP String questions with my current level of Google-fu.

custom-sensor powershell sccm string

Created on Sep 27, 2019 5:49:56 PM

Last change on Sep 30, 2019 4:18:54 AM by  Sven Roggenhofer [Paessler Technical Support]



1 Reply

Votes:

0

Hi,

Unfortunately it is not possible to show a date format as a text in a channel. I would recommend ro rewrite your script to calculates the difference between today's date and last update date. After this you can use <unit> Time Seconds to display the difference and convert it to hours if necessary.
You'll find more information here

Kind regards.

Created on Sep 30, 2019 1:14:45 PM by  Marijan Horsky [Paessler Support]




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.