Posted On March 29, 2019

getDCTimeSources

kimconnect 0 comments
blog.KimConnect.com >> Codes >> 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 *

Related Post

Basic HTML and HTML5: Add a Submit Button to a Form

<h2>CatPhotoApp</h2><main><p>Click here to view more <a href="#">cat photos</a>.</p><a href="#"><img src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying…

How To Modify a Windows Service

Here's the freebie code: # Version 0.02 $serviceName='Windows_Exporter' $newExePath=$false $newSwitches=" --log.format logger:eventlog?name=$serviceName --collectors.enabled os,cpu,cs,logical_disk,net,tcp,service,textfile" function…

Querying Internal DNS for Host Record for iDRAC IPs

Copy / Paste for quick results: $domain='hooli.com'$records=Get-DnsServerResourceRecord -ZoneName $domain -ComputerName $env:USERDNSDOMAIN$records|?{$_.HostName -like '*drac*' -and $_.RecordType…