Contact Info

Crumbtrail

ActiveXperts.com » Administration » Powershell » Powershell 2.0 » Select-String

Select-String - Powershell 2.0 CmdLet

Microsoft Windows PowerShell is a command-line shell and scripting tool based on the Microsoft .NET Framework. It is designed for system administrators, engineers and developers to control and automate the administration of Windows and applications.

More than hundred command-line tools (so called "cmdlets") can be used to perform system administration tasks and Windows Management Instrumentation (WMI). These cmdlets are easy to use, with standard naming conventions and common parameters, and standard tools for piping, sorting, filtering, and formatting data and objects.

Select-String


Short description
Finds text in strings and files.

Syntax
Select-String [-Path] <string[]> [-Pattern] <string[]> [-AllMatches] [-CaseSensitive] [-Context <Int32[]>] [-Encodi

Description
The Select-String cmdlet searches for text and text patterns in input strings and files. You can use it like Grep i
n UNIX and Findstr in Windows.

Select-String is based on lines of text. By default, Select-String finds the first match in each line and, for each
 match, it displays the file name, line number, and all text in the line containing the match. 

However, you can direct it to detect multiple matches per line, display text before and after the match, or display
 only a Boolean value (true or false) that indicates whether a match is found.

Select-String uses regular expression matching, but it can also perform a simple match that searches the input for 
the text that you specify. 

Select-String can display all of the text matches or stop after the first match in each input file. It can also dis
play all text that does not match the specified pattern. 

You can also specify that Select-String should expect a particular character encoding, such as when you are searchi
ng files of Unicode text.