Searching
Find text inside files and files anywhere.
Updated
Finding Text
- Finding Text: Select-String (Apprentice): Select-String searches the text inside files for a word, in one file or in many at once, and shows each matching line with its file name and line number, as objects you can pick from like any other.
Finding Files
- Finding Files: Get-ChildItem -Recurse (Apprentice): Get-ChildItem -Recurse looks in a folder and in every folder inside it, so -Filter finds a file by its name wherever it is, Where-Object finds files by size or date, and Select-String can then search the text inside them all.
Patterns
- Patterns: Regular Expressions with -match (Journeyman): A regular expression describes the shape of the text you want, such as two letters, a dash and some digits, and -match tests text against it, $Matches holds what it found, and Select-String uses the same patterns across many files.
Exercise: The Archive Detective
- Exercise: The Archive Detective (Apprentice): Solve the case of the archive's missing telescope with PowerShell's searches, a pattern through two weeks of door logs, the staff list, the lockers and the storage room, and let a Pester check tell you which answers are right.