I'm trying to to write output to a logfile with today's date and time in the name of the file, so i'd have a new file for each day's transfer activities.
Logging works fine if i don't insert a date/time variable into the filename like so:
$session = New-Object WinSCP.Session $session.SessionLogPath = "X:\Logs\TransferLog.log"
But if i try and enter the date/time variable - it tries but then fails:
$DateTime = Get-Date -format yyyy/MM/dd $session = New-Object WinSCP.Session $session.SessionLogPath = "X:\Logs\TransferLog-$DateTime.log"
Can't open log file 'X:\Logs\TransferLog-2018/09/25.log'. System Error. Code: 2. The system cannot find the file specified"