I have got a script and it works ok but I want to add more command to empty the folder when all these tasks finished but not sure how as I tried to add Remove-Item -path 'E:\id\Upload\* it doesn't seem to work. Could someone please advise? param ( $localPath
= "E:\id\Upload\*.*", $backupPath = "E:\id\Archive", $backupPath2 = "E:\id\Archive2", ) try { # Connect $session.Open($sessionOptions) # Upload files, collect results $transferResult = $session.PutFiles($localPath, $remotePath,
$False, $transferOptions) # Iterate over every transfer foreach ($transfer in $transferResult.Transfers) { # Success or error? if ($transfer.Error -eq $Null) { Write-Output "$(Get-Date) Upload of $($transfer.FileName) succeeded, moving to backup">> $logFile # Upload succeeded, move source file to backup Move-Item $transfer.FileName $backupPath Move-Item $transfer.FileName $backupPath2 } } }
↧