1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/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;