• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 393
  • Last Modified:

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

Script that would show the time on all Domain Controllers in active directory
0
mjm21
Asked:
mjm21
1 Solution
 
AnuroopsunddCommented:
http://gallery.technet.microsoft.com/scriptcenter/Determine-a-computers-time-4b3063e2

this is powershell script..

Function Get-NTPSource{
 
Param(
    [Parameter(ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0)]
    [Alias('Name')]
    [string[]]$Computername=$Env:Computername
    )
 
Process
    {
    foreach ($Computer in $Computername)
        {
        $ntps = w32tm /query /computer:$Computer /source
        new-object psobject -property @{
            Name = $Computer
            NTPSource = $ntps
            }
        }
    }
}
0
 
als315Commented:
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)
Next
Next

Open in new window

0
 
mjm21Author Commented:
Excellent!  Tried the VBscript and worked like a charm.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now