Question

  • starting situation: a lot of servers in over 50(worst case) different languages. Each server may have different language/date settings. OS is w2k3 and w2k8r2. I want to collect the scheduled tasks from all these servers. Especialy the dates have to be in one culture-pattern, because i want to upload the collected files into a database. I prefer a solution which works with both OS', except no other thing works well.
  • first idea: collect data with cmd command "schtasks /query /fo csv /v >file.txt". this works great and i get all information i need. (In 2k3 and 2k8 is the order of the columns different; but this can be handled in c#). Problem: in this solution sucks the date-thing(different date formats cause of the language settings) - i dont want to parse this manually.
  • second idea: get the scheduled tasks via wmi. easily found a site on msdn. problem: "this class can only return jobs that are created using either a script or AT.exe. It cannot return information about jobs that are either created by or modified by the Scheduled Task wizard." I know that about 30 - 40 % of the schtasks on the server was created manually(so over the task wizard).
  • question: so, how can i get all the schtasks-information without manualy parsing date information?
Was it helpful?

Solution

new idea - write a script which collects systeminformation via 2 ways from the server. first with systeminfo wmi and second with cmd command "systeminfo >file.txt".

the systeminfowmi-file contains the installdate in unique pattern (eg: 20121114094908.000000+060). the cmd-command's file contains the culture-related install date: (e.g.: 14.11.2012, 09:49:08)

with this information i wrote a algorithm which search the parts of the date and time given from the wmifile, in the cmd-commands's file. with this i know the order of year/month/day etc. without knowing which language/date settings are used in this server.(of course you be able to re-conclude this, but i dont care about this).

The collecting script (sysinfo wmi and the sysinfo cmd) runs daily. After that runs the date-identification. And as result of this, there will be created a unique date-converting-key for each server. This information were loaded into a database. allover, you will get in future via a stored procedure all server names with the respective date-converting-key - then you will be able to convert each date exactly.

and again thanks to user2199816 - his solution work well too.

OTHER TIPS

use your command line task to file.txt and import that file into Excel. Then use the date/time formatting to see if it will auto parse them correctly.

http://excelsemipro.com/2011/06/regional-date-formats-in-excel/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top