Solved

Create SNTP Report for AD Domain?

Posted on 2011-09-27
7
414 Views
Last Modified: 2012-05-12
Does any one know of a tool that could pull the NTP information from every windows server in a domain? I want to make sure that all of the 100+ servers I'm in charge of are all pointing to the same place.

Thanks!
0
Comment
Question by:THe_Revolver
  • 3
  • 2
  • 2
7 Comments
 
LVL 6

Accepted Solution

by:
netjgrnaut earned 500 total points
ID: 36710961
The syntax of this command is:

NET TIME
[\\computername | /DOMAIN[:domainname] | /RTSDOMAIN[:domainname]] [/SET]
         [\\computername] /QUERYSNTP
         [\\computername] /SETSNTP[:ntp server list]

So (assuming you've got a domain admin account handy), you need only script the NET TIME command against a list of servers.

Personally, I prefer PowerShell.  The following assumes you have a list of your servers in a text file (servers.txt).  Here's a quick-n-dirty...

$result = ""
gc C:\Users\me\Documents\servers.txt | 
% { 
    $winsvr = "\\" + $_
    $result += "-----"
    $result += $winsvr
    $result += net time $winsvr /querysntp
}
Out-File C:\Users\me\Documents\results.txt -InputObject $result -Encoding default

Open in new window


This will produce a file that looks like this...

-----
\\SERVER01
The current SNTP value is: time.windows.com,0x1

The command completed successfully.

-----
\\SERVER02
This computer is not currently configured to use a specific SNTP server.

The command completed successfully.

-----
\\SERVER03
This computer is not currently configured to use a specific SNTP server.

The command completed successfully.


Hope that helps!
0
 
LVL 8

Expert Comment

by:Amitabh Singh
ID: 36710988
hi try this
for /F "tokens=1 delims= " %%s in (servers.txt) do for /f "tokens=*" %%x in ('reg query "\\%%s\HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Parameters /v NtpServer^|find /i "REG_SZ""') do echo %%s;%%x>>output.csv

Open in new window

create a new text file past fallowing code save as "run.bat"
create a new text file servers.txt and provide list of server in it
open cmd and run run.bat
it will create a file called output.csv you able to open this file in excel for batter view

code Example  
----------------------------------------------------------------------------------------------------------
D:\>for /f "tokens=*" %x in ('reg query HKLM\SYSTEM\CurrentControlSet\Services\W
32Time\Parameters /v NtpServer ^|find /i "REG_SZ"') do echo %hostname%;%x

D:\>echo localhost;NtpServer    REG_SZ  time.windows.com,0x1
MYPC01;NtpServer     REG_SZ  time.windows.com,0x1

D:\>
0
 

Author Comment

by:THe_Revolver
ID: 36710995
I'm not all that familiar with PowerShell but I will tinker around a bit. I also do not have a list of servers. I could make one pretty quickly though. What would the list look like?
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 8

Expert Comment

by:Amitabh Singh
ID: 36711012
the list for my bat looks like fallowing format File name servers.txt
Server1
server2
Server3
0
 
LVL 6

Expert Comment

by:netjgrnaut
ID: 36711017
One server name per line. If all the servers are in the same domain, and DNS is working as expected, just the hostname should do.

SERVER01
SERVER02
SERVER03

If needs be, you can use the FQDN...

SERVER01.mydomain.local
SERVER02.mydomain.local
...
0
 

Author Comment

by:THe_Revolver
ID: 36711020
Makes sense. I will give it a go and report back. Thanks guys!
0
 

Author Closing Comment

by:THe_Revolver
ID: 36713325
This was a perfect explanation and worked flawlessly. For having almost no scripting experience and zero powershell experience, I was able to use this solution quite easily.

Thanks!
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
This article demonstrates probably the easiest way to configure domain-wide tier isolation within Active Directory. If you do not know tier isolation read https://technet.microsoft.com/en-us/windows-server-docs/security/securing-privileged-access/s…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question