Script that would show the time on all Domain Controllers in active directory

Posted on 2012-04-12
Medium Priority
Last Modified: 2012-04-16
Script that would show the time on all Domain Controllers in active directory
Question by:mjm21
LVL 17

Expert Comment

ID: 37838740

this is powershell script..

Function Get-NTPSource{
    foreach ($Computer in $Computername)
        $ntps = w32tm /query /computer:$Computer /source
        new-object psobject -property @{
            Name = $Computer
            NTPSource = $ntps
LVL 41

Accepted Solution

als315 earned 2000 total points
ID: 37838797
This is vbs:
Set objOU = GetObject("LDAP://ou=Domain Controllers, dc=YourDomain, dc=local")
objOU.Filter = Array("Computer")
For Each objComputer in objOU
Set objWMIService = GetObject("winmgmts:\\" & objComputer.CN & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * From Win32_LocalTime")
For Each objItem in colItems
    strTime = objItem.Hour & ":" & objItem.Minute & ":" & objItem.Second
    dtmTime = CDate(strTime)
    Wscript.Echo objComputer.CN & ": " & FormatDateTime(dtmTime, vbFormatLongTime)

Open in new window


Author Comment

ID: 37853088
Excellent!  Tried the VBscript and worked like a charm.

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

In current releases of Windows 10, MS removed the ability to format a volume with ReFS. That feature is moved to Windows 10 Pro for Workstations. The requisite files exist in Pro, but functionality is locked and/or otherwise unavailable. A $125 upgr…
This tutorial shows a simple method of resetting a forgotten Windows 10 Password, on both a Physical and VM VirtualBox machine without the need for any third-party tools. Both Local and Microsoft Connected accounts are covered. Enjoy...
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…

627 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