Question:
Can the select-Object be used like so to match either?
1 2 |
If ((Get-content $file | select-object -last 1) -match 'deleted' -or 'return'){"yes"} else {"No"} |
This doesn’t produce error but will tell me yes regardless of the last string matched in $file. I would like to do display a Yes if either match.
Answer:
You can use alternation in the regex:
1 2 |
If ((Get-content $file | select-object -last 1) -match 'deleted|return'){"yes"} else {"No"} |