Reputation: 149
Can the select-Object be used like so to match either?
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.
Upvotes: 4
Views: 9083
Reputation: 68273
You can use alternation in the regex:
If ((Get-content $file | select-object -last 1) -match 'deleted|return'){"yes"} else {"No"}
Upvotes: 13