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

How to Import Files Into a Docker Container

1. Use SCP to copy files to the remote server while logged onto the local…

How to Search for Installed Application by Name in PowerShell

One can search using the known Vendor or application Name as illustrated below: [testwindows]: PS…

PowerShell: Unjoin Computer From Domain

# unjoinComputerFromDomain.ps1 # Version 0.02 # Notes: # - This function doesn't delete the referenced…
Other project: DragonCoin.com