I have a requirement to upload multiple files to SFTP server from my machine using powershell.i have created the following scripts for the same . the script is working fine . but need to check file existence before upload to SFTP server .
the following are the script i used for upload
$username = "UserName"
$password = "Password" | ConvertTo-SecureString -AsPlainText -Force
$server = "xxxxx"
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList
$username,$password
Get-SFTPSession | Remove-SFTPSession
$SFTPSession=New-SFTPSession -ComputerName $server -Credential $credential -Port xxxx
$FilePath = get-childitem "D:\Test\xx*"
$SftpPath = '/D:/xxx/xxx/Test'
ForEach ($LocalFile in $FilePath)
{
Set-SFTPFile -SessionId $SFTPSession.SessionID -LocalFile $LocalFile.fullname -RemotePath $SftpPath -Overwrite
}
Please any body advice me on to check multiple files existence before uploading and only upload files which is not exist in server .
Thanks in advance