Submit a ticketCall us

Systems Monitoring for Dummies
Our new eBook will teach you the fundamentals and help you create monitors and alerts that are effective, meaningful, and actionable. Monitoring is more than a checkbox on your to-do list. This free eBook will give you practical advice to help you succeed in all aspects of monitoring – discovery, alerting, remediation, and troubleshooting. Don’t miss out on this indispensable resource for newbies, experienced IT pros, and everyone in between. Register Now.

Home > Success Center > Server & Application Monitor (SAM) > Server Clock Drift Template Fails on Agent Node in SAM

Server Clock Drift Template Fails on Agent Node in SAM

Updated November 30, 2017


This article details a resolution in regards to the failure of the "Server Clock Drift (PowerShell)" template to run on the Agent Node in SAM when the default polling method is set to "Agent".



  • SAM v6.4


The following command works correctly only for agentless polling:

$remoteServerTime = Get-WmiObject Win32_UTCTime -ComputerName $


-Credential $




On an Agent node, the command fails because these credentials cannot be used for a local connection.


You can use a simpler script that receives the clock drift directly from the NTP server without the complicated mathematics necessary for remote polling:

$ntpServer = $args.get(0);
if (!$ntpServer)
    Write-Host "Message: Can't find ""ntpServer"" argument. Check documentation.";
    exit 1;
$ntpQuery = Invoke-Expression "w32tm /monitor /computers:$ntpServer" | Out-String;
$findSkew = [regex]"(?:NTP\: )(?<Value>[^s]+)";
if ($ntpQuery -match $findSkew)
    $ntpToLocalSkew = [double]::Parse($Matches['Value'])
    $roundedSkew = [math]::Round($ntpToLocalSkew, 2)
    Write-Host "Message: Clock drift: ${roundedSkew}s"
    Write-Host "Statistic: $([math]::Abs($roundedSkew))"
    exit 0
    Write-Host "Message: Unable to query NTP server $ntpServer."
    exit 1




Last modified