Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: CalculateFileChecksum returns "Operation not supported"

As you can see in the log, none of the mentioned commands are supported:

> 2016-04-01 16:24:37.917 FEAT
< 2016-04-01 16:24:37.935 211-Extensions supported
< 2016-04-01 16:24:37.935 AUTH TLS
< 2016-04-01 16:24:37.935 PBSZ
< 2016-04-01 16:24:37.935 PROT
< 2016-04-01 16:24:37.935 211 end
othmane

Re: CalculateFileChecksum returns "Operation not supported"

Ok,
It may be not supported, but I share anyway my script with the whole log session .


SCRIPT:

param (

    $localPath = "E:\xxxx\IMGP1280.JPG",
    $remotePath = "/IMGP1280.JPG",
    $logfileName = $(Get-Date -f "dd-MM-yyyy"),
    $remoteChecksumAlg = "HASH"
)

    # Load WinSCP .NET assembly
    Add-Type -Path "C:\FTPSynch\winscp577automation\WinSCPnet.dll"

# Setup session options
    $sessionOptions = New-Object WinSCP.SessionOptions -Property @{
        Protocol = [WinSCP.Protocol]::ftp
        FtpSecure = [WinSCP.FtpSecure]::Implicit
        HostName = "xxxx.xxxx-xxxx.net"
        UserName = "xxxx@xxxx.xxxx-fichiers.net"
        Password = "xxxx"
        PortNumber = "990"
        FtpMode = "Passive"
        TlsHostCertificateFingerprint = "xxxx"
    }
 
 
    $session = New-Object WinSCP.Session
    $session.SessionLogPath = "C:\FTPSynch\Log_files\winscpCHECKsum.log"

try
{
    Write-Host $localPath
 
    # Calculate local file checksum
    $sha1 = [System.Security.Cryptography.SHA1]::Create()
    $localStream = [System.IO.File]::OpenRead($localPath)
    $localChecksum = [System.BitConverter]::ToString($sha1.ComputeHash($localStream))
 
    Write-Host $localChecksum
 
    try
    {        $session.Open($sessionOptions)
        Write-Host $remotePath
 
        # Calculate remote file checksum
        $remoteChecksum = [System.BitConverter]::ToString($session.CalculateFileChecksum($remoteChecksumAlg, $remotePath))

        Write-Host $remoteChecksum
    }
    finally
    {
        # Disconnect, clean up
        $session.Dispose()
    }
 
    # Compare cheksums
    if ($localChecksum -eq $remoteChecksum)
    {
        Write-Host "Match"
        $result = 0
    }
    else
    {
        Write-Host "Does NOT match"
        $result = 1
    }
}
catch [Exception]
{
    Write-Host $_.Exception.Message
    $result = 1
}
 
# Pause if -pause switch was used
if ($pause)
{
    Write-Host "Press any key to exit..."
    [System.Console]::ReadKey() | Out-Null
}
 
exit $result


LOG

. 2016-04-01 16:24:35.721 WinSCP Version 5.7.7 (Build 6257) (OS 6.3.9600 - Windows Server 2012 R2 Standard)

. 2016-04-01 16:24:35.721 Configuration: nul
. 2016-04-01 16:24:35.721 Log level: Normal
. 2016-04-01 16:24:35.721 Local account: xxxxxxxxx\Administrateur
. 2016-04-01 16:24:35.721 Working directory: C:\FTPSynch\winscp577automation
. 2016-04-01 16:24:35.721 Process ID: 11168
. 2016-04-01 16:24:35.722 Command-line: "C:\FTPSynch\winscp577automation\winscp.exe" /xmllog="C:\Users\Administrateur\AppData\Local\Temp\2\wscp4B00.02DA4974.tmp" /xmlgroups /nointeractiveinput /dotnet=577  /ini=nul /log="C:\FTPSynch\Log_files\winscpCHECKsum.log"  /console /consoleinstance=_19200_14011464_481
. 2016-04-01 16:24:35.722 Time zone: Current: GMT+2, Standard: GMT+1 (Paris, Madrid), DST: GMT+2 (Paris, Madrid (heure d’été)), DST Start: 27/03/2016, DST End: 30/10/2016
. 2016-04-01 16:24:35.722 Login time: vendredi 1 avril 2016 16:24:35
. 2016-04-01 16:24:35.722 --------------------------------------------------------------------------
. 2016-04-01 16:24:35.722 Script: Retrospectively logging previous script records:
> 2016-04-01 16:24:35.722 Script: option batch on
< 2016-04-01 16:24:35.722 Script: batch           on       
< 2016-04-01 16:24:35.722 Script: reconnecttime   120       
> 2016-04-01 16:24:35.722 Script: option confirm off
< 2016-04-01 16:24:35.722 Script: confirm         off       
> 2016-04-01 16:24:35.722 Script: option reconnecttime 120
< 2016-04-01 16:24:35.722 Script: reconnecttime   120       
> 2016-04-01 16:24:35.722 Script: open ftp://xxxxx%40xxxxx.xxxxx-xxxxx.net:***@xxxxx.xxxxx-xxxxx.net:990 -implicit -certificate="xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" -passive=1 -timeout=15
. 2016-04-01 16:24:35.722 --------------------------------------------------------------------------
. 2016-04-01 16:24:35.722 Session name: xxxxx@xxxx.xxxxx-xxxxx.net@xxxxx.xxxxx-xxxxx.net (Ad-Hoc site)
. 2016-04-01 16:24:35.722 Host name: xxxx.xxxxx-xxxxx.net (Port: 990)
. 2016-04-01 16:24:35.722 User name: xxxxx@xxxxx.xxxxx-xxxxx.net (Password: Yes, Key file: No)
. 2016-04-01 16:24:35.722 Transfer Protocol: FTP
. 2016-04-01 16:24:35.722 Ping type: C, Ping interval: 30 sec; Timeout: 15 sec
. 2016-04-01 16:24:35.722 Disable Nagle: No
. 2016-04-01 16:24:35.722 Proxy: none
. 2016-04-01 16:24:35.722 Send buffer: 262144
. 2016-04-01 16:24:35.722 UTF: 2
. 2016-04-01 16:24:35.722 FTP: FTPS: Implicit TLS/SSL; Passive: Yes [Force IP: A]; MLSD: A [List all: A]
. 2016-04-01 16:24:35.722 Session reuse: Yes
. 2016-04-01 16:24:35.722 TLS/SSL versions: TLSv1.0-TLSv1.2
. 2016-04-01 16:24:35.722 Local directory: default, Remote directory: home, Update: Yes, Cache: Yes
. 2016-04-01 16:24:35.722 Cache directory changes: Yes, Permanent: Yes
. 2016-04-01 16:24:35.722 Timezone offset: 0h 0m
. 2016-04-01 16:24:35.722 --------------------------------------------------------------------------
. 2016-04-01 16:24:35.836 Connecting to xxxxxx.xxxxx-xxxxx.net:990 ...
. 2016-04-01 16:24:35.907 Connected with xxxxx.xxxxx-xxxxx.net:990, negotiating TLS connection...
. 2016-04-01 16:24:37.262 Verifying certificate for "xxxxx" with fingerprint xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx and 18 failures
. 2016-04-01 16:24:37.271 Certificate for "xxxxxxxxxx" matches configured fingerprint
. 2016-04-01 16:24:37.271 Using TLSv1, cipher TLSv1/SSLv3: AES128-SHA, 1024 bit RSA
. 2016-04-01 16:24:37.272 TLS connection established. Waiting for welcome message...
< 2016-04-01 16:24:37.408 220 xxxx-xxxxxx.net [xxx.xx.xxx.xxwith SSL] - votre IP est xx.xxx.xx.xx
> 2016-04-01 16:24:37.408 USER xxxxx@xxxxx.xxxxx-xxxxx.net
< 2016-04-01 16:24:37.832 331 Mot de passe obligatoire
> 2016-04-01 16:24:37.832 PASS ********
< 2016-04-01 16:24:37.895 230 Bienvenue sur xxxxx.xxxxx-xxxxx.net, xxxxxtest (acces client) - espace libre : 46045 Mo / 51200 Mo
> 2016-04-01 16:24:37.895 SYST
< 2016-04-01 16:24:37.917 215 UNIX Type: L8
> 2016-04-01 16:24:37.917 FEAT
< 2016-04-01 16:24:37.935 211-Extensions supported
< 2016-04-01 16:24:37.935   AUTH TLS
< 2016-04-01 16:24:37.935   PBSZ
< 2016-04-01 16:24:37.935   PROT
< 2016-04-01 16:24:37.935 211 end
> 2016-04-01 16:24:37.935 PBSZ 0
< 2016-04-01 16:24:37.953 200 ok
> 2016-04-01 16:24:37.953 PROT P
< 2016-04-01 16:24:37.971 200 ok
. 2016-04-01 16:24:37.972 Connected
. 2016-04-01 16:24:37.972 --------------------------------------------------------------------------
. 2016-04-01 16:24:37.972 Using FTP protocol.
. 2016-04-01 16:24:37.972 Doing startup conversation with host.
> 2016-04-01 16:24:37.973 PWD
< 2016-04-01 16:24:37.992 257 "/" is current directory
. 2016-04-01 16:24:37.992 Getting current directory name.
. 2016-04-01 16:24:37.992 Startup conversation with host finished.
< 2016-04-01 16:24:37.992 Script: Active session: [1] xxxxx@xxxxx.xxxxx-xxxxx.net@xxxxx.xxxxx-xxxxx.net
> 2016-04-01 16:24:38.151 Script: pwd
< 2016-04-01 16:24:38.152 Script: /
> 2016-04-01 16:24:38.187 Script: checksum -- "" "/IMGP1280.JPG"
< 2016-04-01 16:24:38.187 Script: Operation not supported.
. 2016-04-01 16:24:38.188 Script: Failed
> 2016-04-01 16:24:38.313 Script: exit
. 2016-04-01 16:24:38.313 Script: Exit code: 1
. 2016-04-01 16:24:38.325 Disconnected from server

martin

Re: CalculateFileChecksum returns "Operation not supported"

But only if the FTP server supports any of the HASH, XSHA1, XSHA256, XSHA512, MD5, XMD5 or XCRC commands. And your remoteChecksumAlg value (what is it?) matches the supported algorithm.

See https://winscp.net/eng/docs/protocols

Please attach a full session log file to confirm.

To generate log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.
othmane

CalculateFileChecksum returns "Operation not supported"

Hello

Checksum calculation is supported using ftps, but i am getting error ----> Operation not supported.
with the following line :

$remoteChecksum = [System.BitConverter]::ToString($session.CalculateFileChecksum($remoteChecksumAlg, $remotePath))

thanks