When using the debug option in Session object WinSCP script will not consecutively run

Advertisement

canthony
Joined:
Posts:
1

When using the debug option in Session object WinSCP script will not consecutively run

I use a PowerShell script to automate a simple transfer from an FTP server to another local server. I started having issues with the transfer and wanted to turn on the debug mode in WinSCP as I do not see any issues in my PowerShell logging. However, when I run my script with a DebugLogPath set, the debug file creates and logs data (however, the log file size stays at 0 kb until I open the file, generally indicating there is a handle to it still), however, if I try and run the script again it fails. If I take the debug flag off, no problems.
[/quote]
Applicable code below. If I run this session, close out PowerShell, then open a new PowerShell console and run again, i get this failure (FYI Line 66 is the session object instantiation[/code] bellow:

2019-08-30:1233:07 : The value supplied is not valid, or the property is read-only. Change the value, and then try again.
2019-08-30:1233:07 : 66
2019-08-30:1233:07 : 20
2019-08-30:1233:07 : $session = New-Object WinSCP.Session -Property @{


$session = New-Object WinSCP.Session -Property @{
            DebugLogPath = $script:debug_log_path
            SessionLogPath = $script:session_log_path
        }
$session_options = New-Object WinSCP.SessionOptions -Property @{
            Protocol = [WinSCP.Protocol]::Sftp;
            HostName = $script:server;
            PortNumber = $script:port;
            UserName = $script:username;
            SecurePrivateKeyPassphrase = $script:secureprivatekeypassword;
            SshPrivateKeyPath = $script:sshprivatekeypath;
            SshHostKeyFingerprint = $script:sshhostfingerprint;      
        }
$session.Open($session_options);
$transfer_results = $session.GetFiles("*", "$script:local_save_to_path\$script:today\", $false, $transfer_options);
$session.Dispose();
$session = $null;

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,603
Location:
Prague, Czechia

Re: When using the debug option in Session object WinSCP script will not consecutively run

Thanks for your report.

Does it help, if you set $session.DebugLogPath = $Null before you dispose the object?

Reply with quote

Advertisement

You can post new topics in this forum