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