Contact Info

Crumbtrail

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

Select-String - Powershell 3.0 CmdLet

ActiveXperts Network Monitor ships with integrated Powershell scripts to monitor complex network. The scripts run out of the box
Download the ActiveXperts Network Monitor FREE version now »

Select-String

Short description
Finds text in strings and files.

Syntax
Select-String [-Pattern] <String[]> [-Path] <String[]> [-AllMatches] [-CaseSensitive] [-Context <Int32[]>] [-Encoding <
String>] [-Exclude <String[]>] [-Include <String[]>] [-List] [-NotMatch] [-Quiet] [-SimpleMatch] [<CommonParameters>]
Select-String [-Pattern] <String[]> [-AllMatches] [-CaseSensitive] [-Context <Int32[]>] [-Encoding <String>] [-Exclude 
<String[]>] [-Include <String[]>] [-List] [-NotMatch] [-Quiet] [-SimpleMatch] -InputObject <PSObject> [<CommonParameter
s>]
Select-String [-Pattern] <String[]> [-AllMatches] [-CaseSensitive] [-Context <Int32[]>] [-Encoding <String>] [-Exclude 
<String[]>] [-Include <String[]>] [-List] [-NotMatch] [-Quiet] [-SimpleMatch] -LiteralPath <String[]> [<CommonParameter
s>]





Description
The Select-String cmdlet searches for text and text patterns in input strings and files. You can use it like Grep in UN
IX and Findstr in Windows. You can type "Select-String" or its alias, "sls".


Select-String is based on lines of text. By default, Select-String finds the first match in each line and, for each mat
ch, it displays the file name, line number, and all text in the line containing the match. However, you can direct it t
o detect multiple matches per line, display text before and after the match, or display only a Boolean value (true or f
alse) 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 display
 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 searching files of Unicode text.