Error Listing Directories starting with numbers
Hey there,
I have combined two scripts form the documentation from here, the problem ist. I am getting a Error everytime I want to Fetch Files/Folders starting with numbers.
Exact Error: "Exception calling Check with 0 arguments: Error listing directory ... Could not retrieve directory listing" and this only happens, if the folders, I want to download starts with numbers.
Btw it's a FTPES
I have combined two scripts form the documentation from here, the problem ist. I am getting a Error everytime I want to Fetch Files/Folders starting with numbers.
Exact Error: "Exception calling Check with 0 arguments: Error listing directory ... Could not retrieve directory listing" and this only happens, if the folders, I want to download starts with numbers.
Btw it's a FTPES
try { $sessionUrl = "ftp://dadsa:dasd@Sdad1.syx:123/" $remotePath = "/test/" $localPath = "E:\test" $lastTimestamp = $Null $timestampFile = "E:\timestamp.txt" # WINSCP DLL $assemblyPath = if ($env:WINSCP_PATH) { $env:WINSCP_PATH } else { $PSScriptRoot } Add-Type -Path (Join-Path $assemblyPath "WinSCPnet.dll") # FTP Session $sessionOptions = New-Object WinSCP.SessionOptions $sessionOptions.ParseUrl($sessionUrl) $session = New-Object WinSCP.Session $sessionOptions.FtpMode = [WinSCP.FtpMode]::passive $session.Open($sessionOptions) try { if (Test-Path $timestampFile) { $lastTimestamp = [DateTime]::ParseExact((Get-Content $timestampFile), 'O', $Null) } else { $lastTimestamp = $Null } $transferOptions = New-Object WinSCP.TransferOptions if ($lastTimestamp -ne $Null) { Write-Host "Downloading files modified after $lastTimestamp..." $transferOptions.FileMask = ("*>" + $lastTimestamp.ToString("yyyy-MM-dd HH:mm:ss")) } else { Write-Host "Downloading all files..." } $transferResult = $session.GetFiles($remotePath, $localPath, $False, $transferOptions) $transferResult.Check() # Find the latest downloaded file $latestTransfer = $transferResult.Transfers | Sort-Object -Property @{ Expression = { (Get-Item $_.Destination).LastWriteTime } } ` -Descending | Select-Object -First 1 if ($latestTransfer -eq $Null) { Write-Host "No files found." } else { $lastTimestamp = (Get-Item $latestTransfer.Destination).LastWriteTime Write-Host ( "Downloaded $($transferResult.Transfers.Count) files, " + "latest being $($latestTransfer.FileName) with timestamp $lastTimestamp.") } Write-Host "Waiting..." Start-Sleep -Seconds 5 Set-Content -Path $timestampFile -Value $lastTimestamp.ToString("O") } finally { # Disconnect, clean up $session.Dispose() } $result = 0 } catch { Write-Host "Error: $($_.Exception.Message)" $result = 1 } # Pause if -pause switch was used if ($pause) { Write-Host "Press any key to exit..." [System.Console]::ReadKey() | Out-Null } exit $result