Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 232413

Re: help getting this script to email a report out of results of NTP time

$
0
0

This will work and just outputs to the screen as expected but when I try to add it to an array it fails? not sure why  

 

$allowedDifferenceSeconds = 20

 

 

get-view -ViewType HostSystem -Property Name, ConfigManager.DateTimeSystem | %{   

    #get host datetime system

    $dts = get-view $_.ConfigManager.DateTimeSystem

   

    #get host time

    $t = $dts.QueryDateTime()

   

    #calculate time difference in seconds

    $s = ( $t - [DateTime]::UtcNow).TotalSeconds

   

    #check if time difference is too much

    if([math]::abs($s) -gt $allowedDifferenceSeconds){

        #print host and time difference in seconds

        $row = "" | select HostName, Seconds

        $row.HostName = $_.Name

        $row.Seconds = $s

        $row

    }

    else{

        Write-Host "Time on" $_.Name "within allowed range"

    }

}


Viewing all articles
Browse latest Browse all 232413

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>