Powershell to check existance of file on ftp server if iexists send email

chetan Vishwakarma 146 Reputation points

Hello Team ,

I want to create a powershell script which checks the existence of file on ftp server and if file exists it will send email.

below sample details I have received from client.

ftp server detail : sftp.abc.com
Port: 23
Username : user1
Password - xyzxyz

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,427 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MotoX80 32,441 Reputation points

    Here's an example that you can modify.

    $cmds =@("open localhost
    dir foo.txt
    $Response = $cmds | ftp.exe 
    $foo = $Response -match 'foo.txt' 
    if ($foo.count -eq 0) {
        "It's not there"
    } else {
        "We found this..."
        "Send your email here."
    0 comments No comments