I'm trying to create a script that searches through a folders and subfolders searching all the text files for 2 strings. If a file is found then it copys this to another folder. I'm able to do it for 1 string but i can't seem to figure out a way to do an AND in it. (Using -and in the select-string doesnt seem to work)
This is what I have so far(Quite sure the -or doesn't work)
$user = "domain\username"
Invoke-Command -ComputerName Server -ScriptBlock {
Get-ChildItem -recurse -Include *.txt -path "File Location" |
Select-String -pattern ("TAX=1+005+0950" -or "TAX=1+5+0950+0") -SimpleMatch |
Copy-Item -Destination "Destination Location"
} -credential $user
I'm needing to search for either of the ones in the code above AND either of these 2 "TAX=1+5+0600" "TAX=1+005+0600"
Any idea how I can do this?
So basically I want to be able to do
Select-String -pattern (TAX=1+005+0950 OR TAX=1+5+0950+0) AND (TAX=1+005+0600 OR TAX=1+5+0600)
-and(actually a&) but I'm not sure if you don't just need another-orinstead (actually a|).select-stringcommands, one from the first list, and one from the second.