File Manager

Path: /opt/chef/embedded/lib/ruby/gems/2.7.0/gems/winrm-fs-1.3.3/lib/winrm-fs/scripts/

Viewing File: checksum.ps1.erb

$p = $ExecutionContext.SessionState.Path
$path = $p.GetUnresolvedProviderPathFromPSPath("<%= path %>")

if (Test-Path $path -PathType Leaf) {
  $cryptoProv = [System.Security.Cryptography.<%= digest %>]::Create()
  $file = [System.IO.File]::Open($path,
      [System.IO.Filemode]::Open, [System.IO.FileAccess]::Read)
  $digest = ([System.BitConverter]::ToString($cryptoProv.ComputeHash($file)))
  $digest = $digest.Replace("-","").ToLower()
  $file.Close()

  Write-Output $digest
}