Quantcast
Viewing all articles
Browse latest Browse all 21975

Powershell find files

Could someone tell me why this would not be returning any results?

My csv is in 2 column with the filepath and filename as the headers, but [knowing that it should present results] it doesn't present any in the text file.

#This is the location of the CSV file
$csvLocation = "C:\test_data2.csv"
$File = "C:\list2.txt"
$filePath = "Path"
$fileName = "File Name"
$csvValues = Import-Csv $csvLocation
foreach($entry in $csvValues)
{
Get-ChildItem -Recurse -Force $entry.$filePath -ErrorAction SilentlyContinue | Where-Object { ($_.PSIsContainer -eq $false) -and  ( $_.Name -like "$entry.$fileName") } | Select-Object Name,Directory| Format-Table -AutoSize * | Out-File $File -append
}
Thank you.

Viewing all articles
Browse latest Browse all 21975

Trending Articles