Link to home
Start Free TrialLog in
Avatar of heydorft
heydorft

asked on

net time vbs script not working

I have a below script

Dim wshShell

Set wshShell = CreateObject("WScript.Shell")
wshShell.Run "%COMSPEC% /c net time \\dc3 /set /y", 0, True

Set wshShell = Nothing

It is suppose to set the time on the domain pcs and servers to dc3 time and all pcs and servers are to draw time from this domain controller(which I have set up to draw time from ntp pool of usa servers)




But when I run net time in command prompt on a pc or other server it shows time drawing from  another server(dc1).

I want all pcs and servers in domain to draw time from dc3 using this script in login script. The script is suppose to do this.......why is it when I run net time on a different pc or server.... it shows pulling from dc1......the below is the full script

ON ERROR RESUME NEXT

Set wshShell = CreateObject("WScript.Shell")
wshShell.Run "%COMSPEC% /c net time \\dc3 /set /y", 0, True
Set wshShell = Nothing
UserString = WSHNetwork.UserName
WSHNetwork.MapNetworkDrive "S:", "\\fileserv\shared"
WSHNetwork.MapNetworkDrive "U:", "\\fileserv\users\" & UserString
WSHNetwork.MapNetworkDrive "g:", "\\rta1\fleet"
WSHNetwork.MapNetworkDrive "K:", "\\keller\keller"



If need be can I change the script to pull from a ntp server and set that into login script?? If so how??


Open in new window

Avatar of Netman66
Netman66
Flag of Canada image

wshShell.Run "C:\Windows\System32\CMD.exe /c net time \\dc3 /set /y", 0, True

Try that.

Avatar of heydorft
heydorft

ASKER

That did not work
Normally, domain members sync with the PDC by default.

You can use Group Policy to push out this change here:

Computer Config>Admin Templates>System>Windows Time Service>Time Providers ::

Enable Windows NTP Client = Enabled.
Configure Windows NTP Client = Enabled.  Set your server FQDN followed by 0x1 (dcs.domain.local,0x1).  Leave the rest alone.

This should by set on a policy above the workstations.  

Make sure that DC3 has been set to sync with a time server on the internet.  You'll also have to tell your other DCs to use this server too or your AD timestamps will be a mess.

ASKER CERTIFIED SOLUTION
Avatar of StuFox100
StuFox100
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial