You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible/library/windows/slurp.ps1

31 lines
472 B
PowerShell

#!powershell
# WANT_JSON
# POWERSHELL_COMMON
$params = Parse-Args $args;
$src = '';
If ($params.src.GetType)
{
$src = $params.src;
}
Else
{
If ($params.path.GetType)
{
$src = $params.path;
}
}
If (-not $src)
{
}
$bytes = [System.IO.File]::ReadAllBytes($src);
$content = [System.Convert]::ToBase64String($bytes);
$result = New-Object psobject;
Set-Attr $result "content" $content;
Set-Attr $result "encoding" "base64";
echo $result | ConvertTo-Json;