Listing files matching wildcard
# Get list of matching files in the directory
$files =
$session.EnumerateRemoteFiles(
$remotePath, ($wildcard = Get-Content "test.txt"), [WinSCP.EnumerationOptions]::None)
# Any file matched?
if ($files.Count -gt 0)
{
foreach ($fileInfo in $files)
{
Write-Host $($fileInfo.Name) with size $($fileInfo.Length)
}
}
else
{
Write-Host "No files matching $wildcard found"
}
Is the bolded section not a valid option? I have 5 different lists that i need to us to download files from an FTP server. i have an option that is doing what i need but i'm not able to log the file it downloads like i can with this code i copied from your site.
When using my list like this it reads the two lines i have in the test file but says acts like there are no matches. if i remove the second line in the file it finds the matches of the single line item.
$files =
$session.EnumerateRemoteFiles(
$remotePath, ($wildcard = Get-Content "test.txt"), [WinSCP.EnumerationOptions]::None)
# Any file matched?
if ($files.Count -gt 0)
{
foreach ($fileInfo in $files)
{
Write-Host $($fileInfo.Name) with size $($fileInfo.Length)
}
}
else
{
Write-Host "No files matching $wildcard found"
}
Is the bolded section not a valid option? I have 5 different lists that i need to us to download files from an FTP server. i have an option that is doing what i need but i'm not able to log the file it downloads like i can with this code i copied from your site.
When using my list like this it reads the two lines i have in the test file but says acts like there are no matches. if i remove the second line in the file it finds the matches of the single line item.