Closed ltiwana closed 4 years ago
interesting, I am using write-error
so try/catch should work. Give some time and ill trying and get this sorted out. Thanks for letting me know.
@ltiwana See if this format works:
try {
Receive-WinSCPItem -WinSCPSession $Session -RemotePath $DownDirS ... -ErrorAction Stop
} catch [System.Exception] {
$Error | Out-String
}
Make sure to include the "-ErrorAction Stop" and "[System.Exception]" parts.
im going to close this. I am able to catch errors with Try, Catch. and its been quite a while since the authors last response.
Please fill in the following fields, replacing the values inside the brackets
{{ }}
.Issue Description
{{ Please provide a description here. }} I am not able to do any error check, in case any of the module commands fail. Nothing shows up under $?, $lastexitcode or Try { } Catch { }
Example
{{ Please provide an example of the code being used. }}
Expected Output
{{ Please provide what expect to happen. }} $? should be False, and try { } catch { } should be able to catch if command-let returns an error
Actual Output
{{ Please provide what actually happened. }}
WinSCP-PowerShell Version
{{ Paste output of
Get-Module -Name WinSCP | Clip
here }}\Environment
{{ Please provide OS Information (Version, Arch, etc), PowerShell Version (Output of
$host
) and what FTP flavor the server is. }}