Re: To count number of files in SFTP server
                You cannot do this with a simple scripting.
Use WinSCP .NET assembly from a PowerShell script.
https://winscp.net/eng/docs/library_powershell
Use
https://winscp.net/eng/docs/library_session_enumerateremotefiles
        Use WinSCP .NET assembly from a PowerShell script.
https://winscp.net/eng/docs/library_powershell
Use
Session.EnumerateRemoteFiles to find the list of matching files.
https://winscp.net/eng/docs/library_session_enumerateremotefiles