Session.DebugLogPath
is a property, which you need to set.
https://winscp.net/eng/docs/library_session#debuglogpath
Session.DebugLogPath
is a property, which you need to set.
Session.DebugLogPath
) for that?
C:\ProgramData\Microsoft\AppV\...
)
try
{
# Load WinSCP .NET assembly
Add-Type -Path "C:\ProgramData\Microsoft\AppV\Client\Integration\76D73676-A43A-4890-9049-8283D31CD7E0\Root\VFS\ProgramFilesX86\WinSCP\WinSCPnet.dll"
# Setup session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::Sftp
HostName = "servername"
UserName = "mgr"
Password = "password"
SshHostKeyFingerprint = "ssh-ed25519 256 #stuff_here#"
}
$session = New-Object WinSCP.Session
try
{
# Connect
$session.Open($sessionOptions)
# Download files
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
$transferResult =
$session.GetFiles("/sunquest/printfiles/testfile.txt", "C:\test", $False, $transferOptions)
# Throw on any error
$transferResult.Check()
# Print results
foreach ($transfer in $transferResult.Transfers)
{
Write-Host "Download of $($transfer.FileName) succeeded"
}
}
finally
{
# Disconnect, clean up
$session.Dispose()
}
exit 0
}
catch [Exception]
{
Write-Host "Error: $($_.Exception.Message)"
exit 1
}
Error: Cannot initialize external console.
Request event
System Error. Code: 2.
The system cannot find the file specified