Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

aksarben

Re: Can’t Set Debug Log Path

Ah, now I get it! Might be worth updating the description in the documentation to clarify that.
martin

Re: Can’t Set Debug Log Path

It's path to a log file, not a path to a directory containing the log file.
So it should be like:
$session.DebugLogPath =
    "C:\Users\Dick\Documents\PowerShell\Scripts\WinSCP.debug.log"

Same for Session.SessionLogPath.
aksarben

Can’t Set Debug Log Path

I’m getting a strange error creating a Session object. Here's the code:
function New-Session {
   [WinSCP.Session]$session = New-Object WinSCP.Session
   $sessionLogPath = $env:TchPublisherSessionLogPath
   if ($sessionLogPath) {
      if (!(Test-Path $sessionLogPath)) {
         Deny-EnvironmentVariable -description "Session log path" -variable "TchPublisherSessionLogPath" -reason $PATH_DOES_NOT_EXIST
      }
      $session.sessionLogPath = $sessionLogPath
   }
   $debugLogPath = $env:TchPublisherDebugLogPath
   if ($debugLogPath) {
      if (!(Test-Path $debugLogPath)) {
         Deny-EnvironmentVariable -description "debug log path" -variable "TchPublisherDebugLogPath" -reason $PATH_DOES_NOT_EXIST
      }
      $session.debugLogPath = $debugLogPath
   }
   $debugLogLevel = $env:TchPublisherLogLevel
   if ($debugLogLevel) {
      if ($debugLogLevel -lt -1 -or $debugLogLevel -gt 1) {
         Deny-EnvironmentVariable -description "log level" -variable "TchPublisherLogLevel" -reason "valid values are -1 to 1"
      }
      $session.debugLogLevel = $debugLogLevel
   }
   return $session
}

I consistently get an error on this line:
$session.debugLogPath = $debugLogPath

The error message:
Exception setting "debugLogPath": "Access to the path 'C:\Users\Dick\Documents\PowerShell\Scripts' is denied."

The path I was going to store for debugLogPath was the same one I just set for sessionLogPath.
I didn’t see anything in the documentation that the two paths have to be different. What am I doing wrong?