Public/Get-WinSCPItemChecksum.ps1
function Get-WinSCPItemChecksum { [CmdletBinding( ConfirmImpact = "Low", HelpUri = "https://github.com/tomohulk/WinSCP/wiki/Get-WinSCPItemChecksum", PositionalBinding = $false )] [OutputType( [Array] )] param ( [Parameter( Mandatory = $true, ValueFromPipelineByPropertyName = $true )] [ValidateScript({ if ($_.Opened) { return $true } else { throw "The WinSCP Session is not in an Open state." } })] [WinSCP.Session] $WinSCPSession, [Parameter( Mandatory = $true )] [String] $Algorithm, [Parameter( Mandatory = $true, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true )] [String[]] $Path ) process { foreach ($pathValue in ( Format-WinSCPPathString -Path $Path )) { try { $output = $WinSCPSession.CalculateFileChecksum( $Algorithm, $pathValue ) Write-Output -InputObject $output } catch { $PSCmdlet.WriteError( $_ ) } } } } |