August 31st, 2013

PowerTip: Use PowerShell to Parse Text Files

Doctor Scripto
Scripter

Summary: Quickly search files for text with Windows PowerShell.

Hey, Scripting Guy! Question How can I use Windows PowerShell to quickly search text files for a string?

Hey, Scripting Guy! Answer Use the Select-String cmdlet and supply a path and a pattern.
          In the following example, I search the current folder for the computer name dc13:

Select-String -Path *.txt -Pattern ‘dc13’

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.