Solved

Create SNTP Report for AD Domain?

Posted on 2011-09-27
7
412 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Computer account cleanup 90 107
Active Directory Photo Tab 4 28
Domain administrator account is locked out 31 64
SBS2008 and windows updates 2 15
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

832 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