0
0
PowerShellscripting~5 mins

Select-String for searching in PowerShell - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the PowerShell cmdlet <code>Select-String</code> do?

Select-String searches text or files for patterns, like the 'find' command. It helps find lines that match a word or phrase.

Click to reveal answer
beginner
How do you search for the word 'error' in a file named log.txt using Select-String?

Use: Select-String -Path log.txt -Pattern 'error'. This shows all lines with 'error' in the file.

Click to reveal answer
intermediate
What does the -CaseSensitive parameter do in Select-String?

It makes the search match only exact letter cases. For example, searching 'Error' won't find 'error' if -CaseSensitive is used.

Click to reveal answer
intermediate
How can you search multiple files at once with Select-String?

Use wildcards in the -Path parameter, like Select-String -Path *.txt -Pattern 'warning' to search all text files.

Click to reveal answer
beginner
What output does Select-String provide when it finds matches?

It shows the file name, line number, and the matching line of text. This helps you quickly find where the pattern appears.

Click to reveal answer
Which parameter specifies the text or files to search in Select-String?
A-Pattern
B-Path
C-CaseSensitive
D-Match
How do you make Select-String search case-sensitively?
AAdd <code>-CaseSensitive</code>
BAdd <code>-IgnoreCase</code>
CUse <code>-ExactMatch</code>
DUse <code>-MatchCase</code>
What does Select-String output when it finds a match?
AFile name, line number, and matching line
BThe whole file content
COnly the matching word
DNumber of matches only
Which wildcard can you use to search all text files with Select-String?
Afile*
Bfile?.txt
Call.txt
D*.txt
What is the purpose of the -Pattern parameter?
ATo specify files to search
BTo output results to a file
CTo specify the text or regex to find
DTo set case sensitivity
Explain how to use Select-String to find a word in multiple files and what output you expect.
Think about searching all .txt files for a word and what you see after running the command.
You got /3 concepts.
    Describe the effect of the -CaseSensitive parameter in Select-String.
    Consider how searching for 'Error' differs from 'error' with this option.
    You got /3 concepts.