alexander7567
alexander7567

Reputation: 664

Posh-SSH is giving an error when in WorkFlow

I wrote a script to export rows from a SQL DB, encrypt them using PGP, then transfer them using POSH-SSH v2.3.0. It all works fine, until I put it in a PowerShell WorkFlow to run multiple at a time.

This particular line is the issue:

Set-SFTPFile -SessionId $sftp.SessionId -LocalFile "$encrypted\$($file.Name).pgp" -RemotePath ".\path"

When running that line, I am getting the below error. If I comment out that line, the error goes away and the script runs fine (minus actually transferring the file).

Microsoft.PowerShell.Utility\Write-Error : Object reference not set to an instance of an object.
At StartExport:20 char:20
+ 
    + CategoryInfo          : NotSpecified: (:) [Write-Error], RemoteException
    + FullyQualifiedErrorId : System.Management.Automation.RemoteException,Microsoft.PowerShell.Commands.WriteErrorCommand
    + PSComputerName        : [localhost]

To me, it looks like there is something with POSH-SSH that is not compatible with PowerShell WorkFlows. Has anyone had any experience with this? I would try to upgrade to v3.0 PSH-SSH, but it is on a pretty locked down server that runs a lot of automation, and it would require me to install a new .NET, which could break many things.

Edit: As a test, I installed POSH-SSH v 2.3.0 on my laptop, got the same error. Then I updated POSH-SSH to version 3.0.0 (the latest) and I still get the same error.

Appreciate any help! I've been stuck on this one for quite a while.

Upvotes: 0

Views: 299

Answers (1)

alexander7567
alexander7567

Reputation: 664

"Module was not written to work in workflows. They are not supported at this time."

-https://github.com/darkoperator/Posh-SSH/issues/173

Not the answer I was hoping for, but now I understand. Still open to any work arounds though.

Upvotes: 0

Related Questions