Select-String: The grep Of Powershell

When writing PowerShell code and you need to search for text inside of a single string or an entire text file, where do you turn? If you’ve used Linux very much, you’re probably familiar with the popular grep utility. The grep utility allows a user to search text using some different options, but this utility doesn’t exist in Windows. Are we out of luck? No. We’ve got the Select-String cmdlet.
Let’s say you’ve got a big string of containing various employee names and addresses. Unfortunately, this string isn’t in any well-known structure, so you’re forced to pull out all of the employee names via text parsing. How would you make that happen? First, let’s start with the example string we’ll be using.

 

Read the full article at Ipswitch.

 

Adam Bertram

Adam Bertram

Chief Automator at Adam the Automator, LLC
Adam Bertram is an independent consultant, technical writer, trainer and presenter. Adam specializes in consulting and evangelizing all things IT automation mainly focused around Windows PowerShell. Adam is a Microsoft Windows PowerShell MVP, 2015 powershell.org PowerShell hero and has numerous Microsoft IT pro certifications. He authors IT pro course content for Pluralsight, is a regular contributor to numerous print and online publications and presents at various user groups and conferences.You can find Adam here on the blog or on Twitter at @adbertram.
Adam Bertram

Latest posts by Adam Bertram (see all)

Leave a Reply