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

Check Servers NSLookup of a Listener to Match Active Node IP

$servers="SQL01","SQL02","SQL03","SQL04" $listener="halistener01" $activeNode="10.10.10.5" # Dynamic Credential method 1 $who = whoami if ($who.Substring($who.length-2, 2)="-admin"){$username=$who;} else…

PowerShell: Adding a New Domain Controller

Error when trying to run DCPROMO on a Windows 2019 Server: ---------------------------Active Directory Domain Services…

PowerShell: Discover Domain Controllers and Classify Each As VM or Physical

Current Version $dcObjects=Get-ADDomainController -Filter * | select Name,OperationMasterRolesforeach ($dc in $dcObjects){ $dcName=$dc.Name $dcRole=$dc.OperationMasterRoles try{ $machineModel=(Get-WmiObject…