0

I have loads of logs on a network drive X:

I have a list of names in a text file say with this syntax DOE, John Daniels, Mary etc....

I want to script something that will read each line and scan my X: drive to find occurences of for example DOE, John and either write to a log or print to screen, sorted by date/time etc.

Any ideas? Cheers, Jimmy

  • Can you be more specific on the "find occurences of" part? Are you looking for filenames with that text or files that contain that text. If filenames, can those be filtered by a specific extension? Are the names really on the same line as shown above? Or is each name on a separate line? – Keith Hill Apr 14 '10 at 17:06
  • What is DOE supposed to be? There are ways to do this, but like all things, they rest on certain assumptions. Guaranteed formatting is one of them. Can you provide some sample input (not from the files themselves.. Just some fake data that is representative of your actual data). If it's as you describe, you could just split each line on commas, or use regular expressions (which are my favorite method, albeit somewhat overkill). Thanks. – PSGuy Sep 12 '17 at 04:39

1 Answers1

0

I would go with log parser. It's a great tool for scanning log files and you can basically write SQL queries against those log files.

If it really needs to feed back into Powershell, you can call log parser from your powershell script, just watch the string escaping. LogParser is a COM component, so if you want to get at the API from your powershell script, that's another option.

Community
  • 1
  • 1
jwmiller5
  • 2,584
  • 1
  • 15
  • 34