Want to delete remote files before download via powershell

Advertisement

shannra
Joined:
Posts:
3

Want to delete remote files before download via powershell

Hello,

i try your scripts to use the .netassemply by powershell. It works perfectly. Now i want to modifie it for one day, but with no success.
I want to empty the remotefolder before i upload my files.
I search here this forum and your documentations but still now, i not find a solution.

It this possible or should i use it in another way??

Reply with quote

Advertisement

shannra
Joined:
Posts:
3

Thanks for you replie, but it seemed not tor work:

I use (its only snippet from the script)
$sessionOptions = New-Object WinSCP.SessionOptions
    $sessionOptions.Protocol = [WinSCP.Protocol]::$protocol
    $sessionOptions.HostName = $hostname
    $sessionOptions.UserName = $username
    $sessionOptions.Password = $password
    #$sessionOptions.SshHostKeyFingerprint = "ssh-rsa 2048 9a:33:4f:9c:2b:5a:ad:ad:6b:f4:67:9f:11:51:d6:ab"
 
    $session = New-Object WinSCP.Session
    try
    {
        
        # Will continuously report progress of synchronization
        $session.add_FileTransferred( { FileTransferred } )
 
        # Connect
        $session.Open($sessionOptions)
        $session.RemoveFiles("/test/*")

I get then in iSE of Powershell:
{WinSCP.SessionRemoteException: Can't get attributes of file

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
31,624
Location:
Prague, Czechia

Please set Session.SessionLogPath and attach the log.
_________________
Martin Prikryl

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum