Same sensor from before (https://kb.paessler.com/en/topic/86773-script-returning-a-string-value) but I'm having trouble getting my time elapsed sensor to actually display the value I'm passing to it.
$module = (Join-Path $(Split-Path $env:SMS_ADMIN_UI_PATH) ConfigurationManager.psd1) Import-module $module $SiteCode = Get-PSDrive -PSProvider CMSITE Set-Location -Path "$($SiteCode.Name):\" $syncResult = get-cmsoftwareupdatesyncstatus $timestamp = get-date $timeDiff = $timestamp - $syncResult.lastSuccessfulSyncTime $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: " + $syncResult.lastSyncErrorCode + "</LimitErrorMsg> </result> <result> <channel>Successful Sync Age</channel> <value>" + $timeDiff.TotalHours + "</value> <unit>TimeHours</unit> <float>1</float> <DecimalMode>All</DecimalMode> <limitMode>1</limitMode> <limitMaxError>170</limitMaxError> <LimitErrorMsg>SCCM has not been able to sync with Microsoft update in 7 days.</LimitErrorMsg> </result> " $xmlOutput = $xmlOutput + "</prtg>" $xmlOutput
When I tweak the channel settings, they are reflected in PRTG (converting the channel to TimeHours, for example). However the value is always zero. If I run the script manually in Powershell the totalHours property seems to be correctly displayed within the 'value' tag.
Add comment