I have a CSV list of numbers that I would like to use Select-String to return the name of the file that the string is in.
When I do this
$InvoiceList = Import-CSV "C:\invoiceList.csv"
Foreach ($invoice in $InvoiceList)
{
$orderFilename = $FileList | Select-String -Pattern "3505343956" | Select Filename,Pattern
$orderFilename
}
It gives me a response, I realize it is in a loop, but it gives me a response (albeit many times). This is what I would like.
Order# 199450619.pdf.txt 3505343956 Order# 199450619.pdf.txt 3505343956
But, when I run this:
$InvoiceList = Import-CSV "C:\invoiceList.csv"
Foreach ($invoice in $InvoiceList)
{
$orderFilename = $FileList | Select-String -Pattern "$invoice" | Select Filename,Pattern
$orderFilename
}
or this
$InvoiceList = Import-CSV "C:\invoiceList.csv"
Foreach ($invoice in $InvoiceList)
{
$orderFilename = $FileList | Select-String -Pattern $invoice | Select Filename,Pattern
$orderFilename
}
I get nothing in return.
I know there is data in $invoice because if I just ouput $invoice, I get all the invoice numbers that are in the CSV.
What am I doing wrong?