Use o curinga *
em -filter "*$($_.Fil)"
.
Por outro lado, o Copy-Item
documentation diz que Seu parâmetro -Path
não aceita caracteres curinga .
$newTarget = "\newpart\xxx\$((Get-Date).ToString('dd-MM-yyyy'))_test"
New-Item -ItemType Directory -Path "$newTarget" -Force
Import-Csv '\csvpath\xxx\file.csv' |
ForEach {
Get-ChildItem "\oldpath\xxx\*$($_.Fil)" -File -ErrorAction SilentlyContinue |
ForEach { Copy-Item -path $PSItem.FullName -Destination "$newTarget" }
}
ou (talvez melhor)
$newTarget = "\newpart\xxx\$((Get-Date).ToString('dd-MM-yyyy'))_test"
New-Item -ItemType Directory -Path "$newTarget" -Force
Import-Csv '\csvpath\xxx\file.csv' |
ForEach {
Get-ChildItem "\oldpath\xxx\*$($_.Fil)" -File -ErrorAction SilentlyContinue |
Copy-Item -Destination "$newTarget"
}