Re: How can i get a Filelist like Get-Childitem
Can you attach a log file for session, where it aborts without any error?
$rz_log = "C:\src\logs\RZ\RZ_log_Log_"+(get-date -format "yy-MM-dd")+".txt"
try
{
# Load WinSCP .NET assembly
# Use "winscp.dll" for the releases before the latest beta version.
[Reflection.Assembly]::LoadFrom("C:\Program Files (x86)\WinSCP\WinSCP.dll") | Out-Null
# Setup session options
$sessionOptions = New-Object WinSCP.SessionOptions
$sessionOptions.Protocol = [WinSCP.Protocol]::ftp
$sessionOptions.HostName = "FTP-Server"
$sessionOptions.UserName = "FTP-User"
$sessionOptions.Password = "FTP-Pass"
$session = New-Object WinSCP.Session
try
{
# Connect
$session.Open($sessionOptions)
$directory = $session.ListDirectory("/clara-17")
Compare-Object -ReferenceObject $(Get-ChildItem 'FolderLocal' -Recurse) -DifferenceObject $directory -Property Name
foreach ($fileInfo in $directory.Files)
{
Write-Host ("{0}" -f
$fileInfo.Name)
}
}
finally
{
# Disconnect, clean up
$session.Dispose()
}
#exit 0
}
catch [Exception]
{
Write-Host $_.Exception.Message
exit 1
}