.FilePart extension get added when we transfer the encrypted files automatically to Client Env

Advertisement

Kiransalunke121
Joined:
Posts:
1

.FilePart extension get added when we transfer the encrypted files automatically to Client Env

$srcpath = 'F:\HSBC\TO HSBC\*.pgp'
$filepath = Get-ChildItem $srcpath -File | Where-Object { $_.Extension -ne '.filepart' }  # Exclude .filepart files
$tarpath = '/'  # Change the tarpath to a single forward slash
$compath = 'F:\BackupSFTP\'
 
Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"
 
$SessionOptions = New-Object WinSCP.SessionOptions
$SessionOptions.Protocol = [WinSCP.Protocol]::Sftp
$SessionOptions.Hostname = "############"
$SessionOptions.Username = "######"
$SessionOptions.PortNumber = "10022"
$SessionOptions.PrivateKeyPassphrase = "######"
$SessionOptions.SshPrivateKeyPath = "##################"
 
# Set the SSH host key fingerprint
$SessionOptions.SshHostKeyFingerprint = "######################"
 
$session = New-Object WinSCP.Session
 
try {
    $session.Open($SessionOptions)
 
    foreach ($file in $filepath) {
        $transferResult = $session.PutFiles($file.FullName, $tarpath)
 
        foreach ($transfer in $transferResult.Transfers) {
            if ($transfer.Error -eq $null) {
                Write-Host "Upload of $($transfer.FileName) Succeeded"
            } else {
                Write-Host "Upload of $($transfer.FileName) Failed: $($transfer.Error.Message)"
            }
        }
    }
} finally {
    $session.Dispose()
}

Description: Error Snap

Screenshot 2023-09-04 134418.png

Reply with quote E-mail

Advertisement

Advertisement

You can post new topics in this forum