Error handling and Powershell

Advertisement

Darkstar
Joined:
Posts:
1
Location:
UK

Error handling and Powershell

Good Afternoon,
I am new to the world of WINSCP and Powershell.
In have written a script to get some files from a server, that works well. However I am trying to capture a success/fail parameter.

I am running the below command, if anyone know how to script testing for success or fail. I would be grateful.

Receive-WinSCPItem -localpath $localpath -RemotePath /users21/test/test.csv

Thank you

Richard

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
29,791
Location:
Prague, Czechia

Re: Error handling and Powershell

Receive-WinSCPItem is a cmdlet from WinSCP PowerShell Wrapper Module
https://github.com/dotps1/WinSCP
So please ask there.

Though I assume you can handle its errors as with any other PowerShell cmdlet.
Google for "powershell handle errors".
See for example the try ... catch construct used in all WinSCP .NET assembly PowerShell (not WinSCP PowerShell Wrapper Module) examples:
https://winscp.net/eng/docs/library_powershell#example

Reply with quote

Advertisement

You can post new topics in this forum