Here's a simpe 'script' that'll do it for you across the domain. Rough
around the edges, but it works.
See the 2 required fields near the top.
Doug
On Error Resume Next
dim strComputer2
Set objExplorer = WScript.CreateObject("InternetExplorer.Application")
gowindow()
' enter your DC that controls time here
strComputer1 = "ntapps"
'strComputer2 = inputbox("client1")
dim objFS,TheFileObj,TheFilePath,dat
' enter the file name of all PC's
TheFilePath="Z:\reboot\timepcs.txt"
set objFS=CreateObject("Scripting.FileSystemObject")
set TheFileObj=objFS.OpenTextFile(ThefilePath,1,false)
Do Until TheFileObj.AtEndOfStream
strComputer2 = TheFileObj.Readline
Set objWMIService1 = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer1 & "\root\cimv2")
Set objWMIService2 =
GetObject("winmgmts:{impersonationLevel=impersonate, " _
& "(Systemtime)}!\\" & strComputer2 & "\root\cimv2")
Set colOSes1 = objWMIService1.ExecQuery("SELECT * FROM
Win32_OperatingSystem")
strTime1 = Now
Set colOSes2 = objWMIService2.ExecQuery("SELECT * FROM
Win32_OperatingSystem")
strTime2 = Now
intSeconds1 = CInt(Left(Right(strTime1, 5), 2))
intSeconds2 = CInt(Left(Right(strTime2, 5), 2))
intDiff = 0
If intSeconds1 <> intSeconds2 Then
intDiff = intSeconds2 - intSeconds1
End If
For Each objOS1 in colOSes1
For Each objOS2 in colOSes2
dtmRefDateTime = objOS1.LocalDateTime
intDateTime1 = Left(dtmRefDateTime, 14)
intDateTime2 = Left(objOS2.LocalDateTime, 14)
If intDiff <> 0 Then
intDateTime1 = intDateTime1 + intDiff
End If
If intDateTime1 = intDateTime2 Then
' gosamewindow(strComputer2)
objExplorer.Document.Body.InnerHTML = "Dates and times on " &
strComputer1 & " and " & strComputer2 & "are equal."
' Wscript.Echo "Dates and times on " & strComputer1 & " and " & _
' strComputer2 & "are equal."
Else
intSet = objOS2.SetDateTime(dtmRefDateTime)
If intSet = 0 Then
' gogoodwindow(strComputer2)
objExplorer.Document.Body.InnerHTML = "Successfully synchronized
date and time on " & strComputer2
' Wscript.Echo "Successfully synchronized date and time on " & _
' strComputer2 & " with reference (" & strComputer1 & ")."
Else
' gobadwindow(strComputer2)
objExplorer.Document.Body.InnerHTML = "Unable to set new date and
time on " & strComputer2
' Wscript.Echo "Unable to set new date and time on " &
strComputer2 & "."
End If
End If
Next
Next
loop
sub gowindow()
objExplorer.Navigate "about:blank"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width=500
objExplorer.Height = 100
objExplorer.Left = 0
objExplorer.Top = 0
Do While (objExplorer.Busy)
Wscript.Sleep 200
Loop
objExplorer.Visible = 1
objExplorer.Document.Body.InnerHTML = "Retrieving account information. "
_
& strComputer2
end sub
sub gogoodwindow(strComputer2)
objExplorer.Document.Body.InnerHTML = "Successfully synchronized date
and time on " & strComputer2
end sub
sub gobadwindow(strComputer2)
objExplorer.Document.Body.InnerHTML = "Unable to set new date and time
on " & strComputer2
end sub
sub gosamewindow(strComputer2)
objExplorer.Document.Body.InnerHTML = "Dates and times on " &
strComputer1 & " and " & strComputer2 & "are equal."
end sub
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Burkes, Jeremy
[Contractor]
Sent: Tuesday, April 05, 2005 2:51 PM
To: [email protected]
Subject: RE: [ActiveDir] time sync script
I believe that Windows time uses the system's BIOS clock in some way.
If your system was old and the BIOS battery had weakened or quit then
the next time you boot the clock would be off by minutes and Windows
would have to update itself again against the domain. At least I think
the above is true I could be wrong.
Jeremy
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Rich Milburn
Sent: Tuesday, April 05, 2005 2:36 PM
To: [email protected]
Subject: RE: [ActiveDir] time sync script
Matt, I did this once with a batch file that ran through a computer list
- something like this:
For %%i in (computers.txt) do net time \\%%i /DOMAIN:yourdomain /SET
I got the computers.txt with a net view >computers.txt I think there is
a /y that causes it to not ask for confirmation.
As I just saw someone else pointed out, no, you shouldn't have to do
this. For some reason we did though, some were out of sync by over 15
minutes.
------------------------------------------------------------------------
---
Rich Milburn
MCSE, Microsoft MVP - Directory Services Sr Network Analyst, Field
Platform Development Applebee's International, Inc.
4551 W. 107th St
Overland Park, KS 66207
913-967-2819
------------------------------------------------------------------------
---
"I am always doing that which I can not do, in order that I may learn
how to do it." - Pablo Picasso
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Adams, Kenneth
W (Ken)
Sent: Tuesday, April 05, 2005 1:27 PM
To: [email protected]
Subject: RE: [ActiveDir] time sync script
If you're talking about a script that runs on the client machines, then
just use the 'net time' command in a logon script.
Ken Adams
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Matt Brown
Sent: Tuesday, April 05, 2005 2:20 PM
To: [email protected]
Subject: [ActiveDir] time sync script
Anybody have a script that can check the time on client machines and
auto sync them with the Domain Controller?
Thanks,
--
Matt Brown
[ SELECT * FROM IT WHERE EyeContact=True ] Information Technology System
Specialist Eastern Washington University
List info : http://www.activedir.org/List.aspx
List FAQ : http://www.activedir.org/ListFAQ.aspx
List archive:
http://www.mail-archive.com/activedir%40mail.activedir.org/
List info : http://www.activedir.org/List.aspx
List FAQ : http://www.activedir.org/ListFAQ.aspx
List archive:
http://www.mail-archive.com/activedir%40mail.activedir.org/
-------APPLEBEE'S INTERNATIONAL, INC. CONFIDENTIALITY NOTICE-------
PRIVILEGED / CONFIDENTIAL INFORMATION may be contained in this message
or any attachments.
This information is strictly confidential and may be subject to
attorney-client privilege. This message is intended only for the use of
the named addressee. If you are not the intended recipient of this
message, unauthorized forwarding, printing, copying, distribution, or
using such information is strictly prohibited and may be unlawful. If
you have received this in error, you should kindly notify the sender by
reply e-mail and immediately destroy this message.
Unauthorized interception of this e-mail is a violation of federal
criminal law.
Applebee's International, Inc. reserves the right to monitor and review
the content of all messages sent to and from this e-mail address.
Messages sent to or from this e-mail address may be stored on the
Applebee's International, Inc.
e-mail system.
List info : http://www.activedir.org/List.aspx
List FAQ : http://www.activedir.org/ListFAQ.aspx
List archive:
http://www.mail-archive.com/activedir%40mail.activedir.org/
List info : http://www.activedir.org/List.aspx
List FAQ : http://www.activedir.org/ListFAQ.aspx
List archive:
http://www.mail-archive.com/activedir%40mail.activedir.org/
Confidentiality Notice: The information contained in this message may be
legally privileged and confidential information intended only for the use of
the individual or entity named above. If the reader of this message is not the
intended recipient, or the employee or agent responsible to deliver it to the
intended recipient, you are hereby notified that any release, dissemination,
distribution, or copying of this communication is strictly prohibited. If you
have received this communication in error please notify the author immediately
by replying to this message and deleting the original message. Thank you.
List info : http://www.activedir.org/List.aspx
List FAQ : http://www.activedir.org/ListFAQ.aspx
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/