ansible/windows/slurp.ps1

34 lines
617 B
PowerShell
Raw Normal View History

#!powershell
# WANT_JSON
2014-06-17 22:44:06 +02:00
$params = New-Object psobject;
If ($args.Length -gt 0)
{
$params = Get-Content $args[0] | ConvertFrom-Json;
}
$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;
$result | Add-Member -MemberType NoteProperty -Name content -Value $content;
$result | Add-Member -MemberType NoteProperty -Name encoding -Value 'base64';
echo $result | ConvertTo-Json;