getDCTimeSources

$domain=(Get-ADDomain).DNSRoot
$dcs=(Get-ADDomainController -Filter * -Server $domain).Hostname
$dcTimeSources=@()

foreach ($dc in $dcs) {
#$timeSource=w32tm /query /computer:$dc /configuration | ?{$_ -match 'ntpserver:'} | %{($_ -split ":\s\b")[1]}
"Checking $dc ..."
try{ $timeSource=w32tm /query /computer:$dc /source}
catch{$timeSource=$_.Exception.Message
    Break;}

$dcTimeSources+=,@{
    dc = $dc
    timeSource = $timeSource
    }
#w32tm /query /computer:$dc /source
#>
}

$dcTimeSources | foreach{
    $_.dc+": "+$_.timeSource;
}

Leave a Reply

Your email address will not be published. Required fields are marked *