 |
|
|
Remote PC time format
Last Post 18 Mar 2010 09:13 AM by El Guido. 3 Replies.
|
Sort:
|
|
Prev Next |
You are not authorized to post a reply. |
|
| Author |
Messages |
 |
El Guido
 New Member Posts:6

 |
| 15 Mar 2010 09:26 AM |
|
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
|
|
|
|
|
aleksandar
 New Member Posts:54

 |
| 15 Mar 2010 12: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 |
|
|
El Guido
 New Member Posts:6

 |
| 16 Mar 2010 03: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
|
|
|
|
|
El Guido
 New Member Posts:6

 |
| 18 Mar 2010 09:13 AM |
|
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.3
|
|
 |