Unable to use variables in .SessionLogPath ?
Hello,
I'm pretty new to all this - but am trying to use the .NET assembly within PowerShell to initiate a WinSCP session to download a few files.
I'm trying to use:
$RUNDATE and $RUNTIME I specify elsewhere as the date and time - I'm using those elsewhere and they're working fine.
If I specify explicitely:
It works fine. But as soon as I add a variable in there, I get errors on running:
Can anyone assist?
I'm pretty new to all this - but am trying to use the .NET assembly within PowerShell to initiate a WinSCP session to download a few files.
I'm trying to use:
$RUNDATETIME = "$RUNDATE" + "_" + "$RUNTIME" $WinSCPLogFile = "$LogPath\$RUNDATETIME WinSCP.log" $session.SessionLogPath = $WinSCPLogFile
$RUNDATE and $RUNTIME I specify elsewhere as the date and time - I'm using those elsewhere and they're working fine.
If I specify explicitely:
$session.SessionLogPath = "C:\test\WinSCP.log"
Exception calling "Open" with "1" argument(s): "Error occurred during logging. It's been turned off. Can't open log file '..\Logs\2025-08-19_13-27 WinSCP.log'. System Error. Code: 2. The system cannot find the file specified"
Can anyone assist?