ansible/library/windows/slurp.ps1

31 lines
472 B
PowerShell
Raw Normal View History

#!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);
2014-06-17 22:44:06 +02:00
$result = New-Object psobject;
Set-Attr $result "content" $content;
Set-Attr $result "encoding" "base64";
echo $result | ConvertTo-Json;