functions/ConvertFrom-Base64.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Function ConvertFrom-Base64 {
    <#
        .SYNOPSIS
        Decode Base64 encoded string
 
        .DESCRIPTION
        Helper function to manage base64 encoded strings
 
        .EXAMPLE
        "Foo" | ConvertFrom-Base64
        >> "Zm9v"
    #>

    [cmdletbinding()]param(
        [Parameter(ValueFromRemainingArguments)]
        [string] $Input,
        [Parameter(ValueFromPipeline)]
        [string] $PipelineInput
    )
    begin {
        if($Input){ return $Input | ConvertFrom-Base64 }
    }
    process {
        [Text.Encoding]::Utf8.GetString([Convert]::FromBase64String($PipelineInput))
    }
}

Export-ModuleMember -Function ConvertFrom-Base64