Hello, thank you for responding so quickly!
The behavior or action I want it to take is to delete the remote files that were successfully downloaded but not the remote directory. The login being used doesn't have sufficient privileges to remove a directory so the permission denied exception is being returned and causing the script to terminate with a failure code.
I've included the script below. The log I attached in the fist post is from the session log file. I'll get you a more complete version if needed asap.
$CurrentDir = Split-Path ((Get-Variable MyInvocation -Scope 0).Value).MyCommand.Path
$ProcessingFolder = "\\local\path\"
Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"
$sessionOptions = New-Object WinSCP.SessionOptions
$sessionOptions.Protocol = [WinSCP.Protocol]::Sftp
$sessionOptions.HostName = ""
$sessionOptions.UserName = ""
$sessionOptions.SshHostKeyFingerprint = ""
$sessionOptions.Timeout = New-TimeSpan -Seconds 30
$session = New-Object WinSCP.Session
$session.SessionLogPath = "$CurrentDir\WinSCP.log"
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Automatic
$transferOptions.FilePermissions = $null
$transferOptions.PreserveTimestamp = $False
$transferResult = $session.GetFiles("/remote/path/", $ProcessingFolder, $True, $transferOptions)
# Disconnect, clean up