Skip to main content

How to convert a file to a base64 string in PowerShell.

# PowerShell 6+
[System.Convert]::ToBase64String((Get-Content '<filepath>' -AsByteStream -Raw))

# Windows PowerShell 5.1
[System.Convert]::ToBase64String((Get-Content '<filepath>' -Encoding Bytes))