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

34 lines
737 B
PowerShell

#!powershell
# WANT_JSON
$params = '{}' | ConvertFrom-Json;
If ($args.Length -gt 0)
{
$params = Get-Content $args[0] | ConvertFrom-Json;
}
$src = '';
If (($params | Get-Member | Select-Object -ExpandProperty Name) -contains 'src')
{
$src = $params.src;
}
Else
{
If (($params | Get-Member | Select-Object -ExpandProperty Name) -contains 'path')
{
$src = $params.path;
}
}
If (-not $src)
{
}
$bytes = [System.IO.File]::ReadAllBytes($src);
$content = [System.Convert]::ToBase64String($bytes);
$result = '{}' | ConvertFrom-Json;
$result | Add-Member -MemberType NoteProperty -Name content -Value $content;
$result | Add-Member -MemberType NoteProperty -Name encoding -Value 'base64';
echo $result | ConvertTo-Json;