File Manager

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

Viewing File: download.ps1.erb

$p = $ExecutionContext.SessionState.Path
$path = $p.GetUnresolvedProviderPathFromPSPath("<%= path %>")
$index = <%= index %>
$chunkSize = <%= chunk_size %>
if (Test-Path $path -PathType Leaf) {
  $file = [System.IO.File]::OpenRead($path)
  $seekedTo = $file.Seek($index, [System.IO.SeekOrigin]::Begin)
  $chunk = New-Object byte[] $chunkSize
  $bytesRead = $file.Read($chunk, 0, $chunkSize)
  $bytes = [System.convert]::ToBase64String($chunk[0..$bytesRead])
  Write-Host $bytes
  exit 0
}
ElseIf (Test-Path $path -PathType Container) {
  exit 2
}
exit 1