I'm working with WinSCP in PowerShell to manage files in a FTP. In using the standard script given on the WinSCP website, I am getting this error:
Unable to find type [WinSCP.EnumerateOptions].
I am working in version 5.13 - fresh off the site.
$remotePath = "ftp://username:password@network:port/relevantfolder/"
$localPath = "C:/Users/me/localdir"
$mask = "*.*"
$files = EnumerateRemoteFiles(
$remotePath, $mask, [WinSCP.EnumerateOptions]::AllDirectories)
foreach ($fileInfo in $files)
{
Write-Host "Downloading $($fileInfo.FullName) ..."
$filePath = [WinSCP.RemotePath]::EscapeFileMask($fileInfo.FullName)
$session.GetFiles($filePath, $localPath + "\*").Check()
}
It's EnumerationOptions
, not EnumerateOptions
.
Session.EnumerateRemoteFiles
is a method, so you need to call it on Session
instance.
The path
argument of Session.EnumerateRemoteFiles
is a path, not an URL:
$remotePath = "/relevantfolder/"