Sample code for 30+ languages & platforms
PowerShell

Base64 Encode a File

_LANGUAGE_ to Base64 encode the contents of a file.

Chilkat PowerShell Downloads

PowerShell
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"

$success = $false

# Get the contents of a file into a base64 encoded string:
$fac = New-Object Chilkat.FileAccess
$strBase64 = $fac.ReadBinaryToEncoded("c:/data/something.pdf","base64")
if ($fac.LastMethodSuccess -ne $true) {
    $($fac.LastErrorText)
    exit
}

# Now write the string to a file:
$success = $fac.WriteEntireTextFile("c:/data/something_pdf_base64.txt",$strBase64,"us-ascii",$false)
if ($success -ne $true) {
    $($fac.LastErrorText)
    exit
}

$("Success!")