Get-WinSCPItemChecksum


Synopsis

Calculates a checksum of a remote object.


Syntax

Get-WinSCPItemChecksum [-WinSCPSession] <Session> [-Algorithm] <String> [-Path] <String[]> [<CommonParameters>]

Description

Use IANA Algorithm to retrieve the checksum of a remote file.


Parameters

WinSCPSession <WinSCP.Session>

A valid open WinSCP Session, returned from New-WinSCPSession.

  • Required: True
  • Position: 0
  • Default Value:
  • Accept Pipeline Input: True (ByValue)
  • Accept Wildcard Characters: False

Algorithm <String>

A name of a checksum algorithm to use. Use IANA name of algorithm or use a name of any proprietary algorithm the server supports (with SFTP protocol only). Commonly supported algorithms are sha-1 and md5.

  • Required: True
  • Position: 1
  • Default Value:
  • Accept Pipeline Input: False
  • Accept Wildcard Characters: False

Path <String[]>

A full path to a remote object to calculate a checksum for.

  • Required: True
  • Position: 2
  • Default Value:
  • Accept Pipeline Input: True (ByPropertyName)
  • Accept Wildcard Characters: False

CommonParameters <CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, PipelineVariable, and OutVariable.


Inputs

WinSCP.Session

  • Represents a session and provides methods for manipulating remote files over SFTP, SCP or FTP session.

String

  • Represents text as a series of Unicode characters.

Outputs

System.Array

  • Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the base class for all arrays in the common language runtime.

Notes

If the WinSCPSession is piped into this command, the connection will be closed and the object will be disposed upon completion of the command. Note that calculation of remote file checksum is supported with SFTP and FTP protocols only, subject to support of respective protocol extension.


Example 1

PS C:\> New-WinSCPSession -Credential (New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $env:USERNAME, (New-Object -TypeName System.Security.SecureString)) -Hostname 'myftphost.org' -Protocol Ftp | Get-WinSCPItemChecksum -Algorithm 'sha-1' -Path '/rDir/file.txt'

Fork me on GitHub