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

PowerShell: Add Local Group Members Onto a Server List

Sometimes, the GUI method of accomplishing tasks is too arduous and error prone. Thus, these…

Terminal Service Auditing – Generate Report of RDP Sessions with Certain Login Dates

# getLoginEvents.ps1 function getLoginEvents{ param( $computername=$env:computername, $daysLimit=30 ) $ErrorActionPreference='stop' try{ $logins=Get-WinEvent -ComputerName $ComputerName -LogName "Microsoft-Windows-TerminalServices-LocalSessionManager/Operational"|…

HTML: Tagging and Jumping to Sections of Page

Each element of an HTML document could be set with a unique ID so that…