Logging to a file with today's date and time
Hi,
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:
But if i try and enter the date/time variable - it tries but then fails:
Even though it seems to accept the variable in the filename it can't find it or create it - but as I've mentioned, works fine without the variable so the same file location.
i know its not permissions since it can write to the same location without the variable inserted.
Any ideas?
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"
Any ideas?