Topic "Problem to call a PowerShell"

Author Message
vinicostasantos
[View user's profile]

Joined: 2016-10-26
Posts: 5
Location: Brasil
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:
Code:
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
vinicostasantos
[View user's profile]

Joined: 2016-10-26
Posts: 5
Location: Brasil
Hi ... I solved it!

Lol was ez

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

Example:

Code:

 }
    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
}
Advertisements

You can post new topics in this forum






Search

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License