I have a list of numbers in a csv formatted like this:
po
123
456
789
I also have a directory with 100+ documents. I need to check each document for each string in the csv. If one of the numbers is in one of the documents, it needs to move it to a different file. This is what I have so far:
$files = Get-ChildItem "\\wh1-app\SPS EDI\ARCHIVE IN\*.txt"
foreach ($file in $files) {
$file = Get-Content $file
$pos = Import-Csv -Path C:\Users\ttilton\Desktop\pos.csv -OutVariable string -ErrorAction SilentlyContinue
foreach ($po in $pos) {
$containsWord = $file | %{$_ -match $po.po}
if ($containsWord -contains $true){
write-host $file + " is " + $po.po
#Copy-Item $file C:\Users\ttilton\Desktop\pos\
}
}
But it doesn't seem to be working. It's running without error, but its not really doing anything.
Any ideas? Thanks!!