Functions/Data/Convert-Base64ToString.ps1
<#
.SYNOPSIS Converts a base-64 encoded value to a string #> function Convert-Base64ToString { [CmdletBinding()] param ( # The value to base-64 decode [Parameter(Mandatory=$true,ValueFromPipeline=$true)] [string[]] $Value, # The encoding to use. Default is UTF8 [Parameter(Mandatory=$false)] [ValidateSet("UTF8","Unicode","ASCII","UTF7","UTF32","BigEndianUnicode")] [string] $Encoding = "UTF8" ) Begin { [Text.Encoding]$Encode = ([System.Text.Encoding]::$Encoding) } Process { $Value | ForEach-Object { if( $_ -eq $null ) { return $null } $Bytes = [Convert]::FromBase64String($_) [string]::new($bytes) } } } |