How to get the current date/time stamp from a network computer?

  • Thread starter Thread starter trytobreak
  • Start date Start date
T

trytobreak

Hi All,

I am a network administrator in a fairly large software company and I
would like to write myself a small utility, which would connect (one
by one) to all machines on the network and get their current date and
time stamps.

This is mostly because of coming DST changes and having hundreds of
machines on the network, I don't want to connect remotely to every and
each server to see if the time is correct.

Is there any function or command in CSHARP which lets me grab a
current date/time from a network computer?

Please let me know, you could save me a lot of time :)

Thanks,
JK
 
Hey,

No offence but if you are the network admin would it not be easier to send a
batch down on next login and force the Internet Time to reset to the most
current "real time"? I admit I might be going off at a tangent slightly but
it could do the job and save you tons of time having to write a tiny app to
do the work windows can on it's own - IF you tell it *grin*...

Something like this in a .bat file
<code>
net stop w32time
w32tm /unregister [ignore error message]
w32tm /unregister [enter a second time]
w32tm /register
reg add hklm\system\currentcontrolset\services\w32time\parameters\ /v
NtpServer /t reg_sz /d time.nist.gov /f
net start w32time
</code>

I think there is/was an error with time.windows.com or another of the time
prefix ones as they don't/won't accept requests in TIME format anymore -
nist.gov will cause no issues.

HTH
Brendon
 
Hi,

I was really looking for an answer to my problem...

Problem is, you see, that we are not syncing (for various reasons)
with time servers.
So I need to know if the time is correct some other way and this would
be the best.

Anyhow, is someone here capable to answer the question? :)

Can I remotely get the network computer's time and date?
 
Assuming that WMI is running on those machines, you should be able to
use the classes in the System.Management namespace to connect to the WMI
service on the machines and get the WMI instance of Win32_OperatingSystem.
From there, you would get the LocalDateTime property from the instance,
which will return the local date and time on the machine.
 
Hi All,

I am a network administrator in a fairly large software company and I
would like to write myself a small utility, which would connect (one
by one) to all machines on the network and get their current date and
time stamps.

This is mostly because of coming DST changes and having hundreds of
machines on the network, I don't want to connect remotely to every and
each server to see if the time is correct.

Is there any function or command in CSHARP which lets me grab a
current date/time from a network computer?

Please let me know, you could save me a lot of time :)

Thanks,
JK


No need to write any code at all, just get a copy of the PsTools from,
<http://www.microsoft.com/technet/sysinternals/utilities/psexec.mspx> and
use "psexec" to run the time command remotely.

Willy.
 
One solution we came up with syncing with machines that didn't support
WMI was to write a file to the computer and then check the latest
write time. It worked well for our needs which didn't require a high
degree of accuracy (within a second was fine, but technique is closer
than that).

Of course it requires write access... :-)

HTH,

Sam
 
Hi All,

I am a network administrator in a fairly large software company and I
would like to write myself a small utility, which would connect (one
by one) to all machines on the network and get their current date and
time stamps.

This is mostly because of coming DST changes and having hundreds of
machines on the network, I don't want to connect remotely to every and
each server to see if the time is correct.

Is there any function or command in CSHARP which lets me grab a
current date/time from a network computer?

Please let me know, you could save me a lot of time :)

Thanks,
JK

Hi there,
Do a Google for NetRemoteTOD c#. There are some examples that PInvoke
that should do what you want.

Cheers,

Steve
http://dunnhq.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top