This is like
grepif you ever encountered that. TheSelect-Stringcmdlet finds a-patternin text.
It has an-allmatchesswitch to … guess what 🙂Get-ChildItem D:\Myscripts -File -Recurse *.sql | Select-String -pattern "drop\s+[?(database|table|login)"will get us all our sql scripts in which we drop a database, table or login.
The returned MatchInfo object holds the matching parts of the script text, and also the name of the file and the line number where the match was found.
Get-ChildItem | Select-String is my most frequently used Powershell pipeline.
Comments closed