Problem to call a PowerShell

Advertisement

vinicostasantos
Joined:
Posts:
5
Location:
Brasil

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

Reply with quote

Advertisement

vinicostasantos
Joined:
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:

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

Reply with quote

Advertisement

You can post new topics in this forum