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

vinicostasantos

Hi ... I solved it!

Lol was ez

I've just needed put my script to run after close the WINSCP connection:

Example:

 }

    finally
    {
        # Disconnect, clean up
        $session.Dispose()
    }
Start-Sleep -s 15
Get-Childitem -r -path "G:\SFTP\*******\" | rename-item -newname { [io.path]::ChangeExtension($_.name, "gpg") }
Start-Sleep -s 10
Get-ChildItem -Path "G:\SFTP\******\" -Recurse -Include *.gpg  | Move-Item -Destination "G:\SFTP\*****" -verbose
    exit 0
}
catch [Exception]
{
    Write-Host ("Error: {0}" -f $_.Exception.Message)
    exit 1
}
vinicostasantos

Problem to call a PowerShell

Hi guys,

I'm trying tocall a powershell script with $session.ExecuteCommand but I'm having this error bellow:

Error: Connection has been unexpectedly closed. Server sent command exit status 1.

Could someone please help me with this?

Here is the command: $session.ExecuteCommand("G:\Scripts\Move.ps1").Check()

Here is the powershell script:
Start-Sleep -s 15

Get-Childitem -r -path "G:\SFTP\****\" | rename-item -newname { [io.path]::ChangeExtension($_.name, "gpg") }
Start-Sleep -s 10
Get-ChildItem -Path "G:\SFTP\****\" -Recurse -Include *.gpg  | Move-Item -Destination "G:\SFTP\****" -verbose