header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

We have a new sponsor!  Introducting Pragma Systems.  See the home page for details.

Remote PC time format
Last Post 18 Mar 2010 05:13 PM by elguido2k. 3 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages Resolved
elguido2kUser is Offline
New Member
New Member
Posts:6
Avatar

--
15 Mar 2010 05:26 PM  
Hello all,

I was wondering if someone with more experience could advise please.

I potentially need to read some logs from many machines in many regions.

As such the datetime format can oscillate (in fact I have found this to be the case already in just my local region) between many types.

As I see it I have 2 solutions:

1) Work out how to retrieve the format which a remote PC uses using PS/.Net (get-date seems to be local and [datetime]::parse doesn't seem to detect switches from say UK to US and I think a switch'd regex against possible formats would be error prone)

2) Work out a reliable way to connect to WMI from PS on many machines and for it to timeout in a reasonable time frame

Could anyone suggest a good way on either, I'm trying to avoid WMI as I have found when scanning machine lists with 2500 hosts in, corrupt WMI etc make the process take far too long (10 mins becomes 6 hrs) even with those tweaks to set timeouts.

Cheers,

Guy
aleksandarUser is Offline
New Member
New Member
Posts:45
Avatar

--
15 Mar 2010 08:02 PM  
A culture-aware way is to use the -as operator: '24.1.2010' -as [DateTime] This time, the string information is interpreted according to your current culture. Does this help?
Follow me on Twitter: http://twitter.com/alexandair
elguido2kUser is Offline
New Member
New Member
Posts:6
Avatar

--
16 Mar 2010 11:54 AM  
Hi Alex,

It does help in that I've learnt something, but I don't think it addresses the problem I have :-/

Here's the scenario, I'm sat here on my en-gb machine, but I am checking 2.5k machines' log files. Now some of those machines have not got the datetime in the log files as en-gb, but en-us

So currently I have to handle:

dd/MM/yyyy HH:mm:ss
M/d/yyyy h:m:ss tt

But the script has the scope to be run on lots of machines globally and not just by me, so whilst I can do a switch to handle the above scenario, I felt the better way would be to retrieve the localization and set the iformat/cultureinfo/provider thing and then do a [datetime]::parseexact using the gathered data.

Does that seem rational, I'm happy to acknowledge any better ways of attacking the problem :)

Cheers,

G
elguido2kUser is Offline
New Member
New Member
Posts:6
Avatar

--
18 Mar 2010 05:13 PM Accepted Answer  
Ok I think I have a solution which is in my mind a bit horrible:

read hcu\\ControlPanel\International\(sShortDate|sTimeFormat)

and from them I can build the datetime format of the user.

If anyone gets a more elegant solution to this problem, I would love to hear it.

Cheers,

G
You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 footer
footer