Functions/Convert-FileToBase64EncodedBytes.ps1
<#
.SYNOPSIS This function converts the contents of a file into Base64 encoded bytes. #> function Convert-FileToBase64EncodedBytes { [CmdletBinding(PositionalBinding=$true)] [OutputType([String])] param ( # The file path [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [String]$path ) # Ensure that the file exists if (!(Test-Path -Path $path -ErrorAction SilentlyContinue)) { return } # Convert the file contents to Base64 encoded bytes and return return [Convert]::ToBase64String((Get-Content -Path $path -Encoding Byte)) } |