Question:
In powershell is that a way to put multiple search pattern ? Example below command, I want to search those string that has ASA or TMP. But it doesn’t work. The search should match as a single word example: ASA is true but TIASAP is false
1 2 |
Get-ChildItem E:\Test\Workflow -Exclude *.bak -Recurse | Select-String -pattern "ASA" -or "TMP" -SimpleMatch | Where-Object LineNumber -le 50 | group path | select name |
Answer:
If you omit the -SimpleMatch
switch, the Select-String cmdlet uses regex
so you can just search for ASA|TMP
:
1 2 |
Get-ChildItem E:\Test\Workflow -Exclude *.bak -Recurse | Select-String -pattern "ASA|TMP" | Where-Object LineNumber -le 50 | group path | select name |