Learn how to encode and decode Base64 text and images in PowerShell with this clear, step‑by‑step tutorial. You’ll see practical one-liners and reusable patterns for converting strings and log files to Base64, decoding them back, handling UTF-8 vs UTF-16, and avoiding common pitfalls like BOM differences between Windows PowerShell 5.1 and PowerShell 7. We’ll also convert images to Base64 and back, and finish with a quick WSL/Linux base64 demo so you can round-trip data between PowerShell and Bash.
#PowerShell #Base64 #WindowsServer #Windows11 #SysAdmin #ITPro #Scripting #Automation #DarienTips #WSL:
You’ll learn
• How to encode plain text into Base64 using PowerShell
• How to decode Base64 back into text for reuse in scripts or files
• Encoding and decoding entire files with Get-Content and Out-File
• Working with UTF‑8 vs UTF‑8 BOM and why it matters
• Encoding images into Base64 for embedding in scripts or JSON
• Decoding Base64 back into image files with proper extensions
• Cross‑platform Base64 encoding/decoding using WSL and native Linux commands
Applies to:
✅ Windows 10, 11
✅ Windows Server 2016 — 2025
✅ Windows PowerShell 5.1
✅ PowerShell 7+ (cross-platform)
✅ WSL / Linux (base64, --decode / -d)
Commands and Scripts (PowerShell & BASH) GitHub:
https://github.com/DariensTips
Chapters:
0:00 Introduction
0:22 Encode Plain Text to Base64
1:44 Decode Base64 to Plain Text
2:20 Text Decode Caveat
4:22 Encode an Image to Base64
4:45 Decode Base64 to an Image File
5:24 Image Decode Caveat
5:59 BONUS: WSL Encode/Decode Base64
6:43 Thank you for watching
7:06 Links & Resources
Links & Resources:
https://en.wikipedia.org/wiki/Byte_or...
https://learn.microsoft.com/en-us/dot...
https://learn.microsoft.com/en-us/dot...
https://learn.microsoft.com/en-us/pow...
https://learn.microsoft.com/en-us/pow...
https://linux.die.net/man/1/base64
https://linuxcommand.org/lc3_man_page...
Glossary:
Base64 – A text-based encoding that represents binary data as ASCII characters (not encryption).
UTF-8 – A variable-length Unicode encoding that is ASCII-compatible and the most common cross-platform text encoding.
UTF-16 – A Unicode encoding that uses 2-byte code units; produces different bytes (and Base64) than UTF-8 for the same text.
BOM (Byte Order Mark) – A special sequence of bytes at the beginning of a UTF-encoded file that indicates encoding and byte order.
Byte Array – A sequence of bytes ([byte[]]) representing raw data that can be converted to/from Base64.
[Convert]::ToBase64String() – .NET method used in PowerShell to convert a byte array into a Base64 string.
[Text.Encoding]::UTF8 – .NET encoding class used to convert text strings to/from byte arrays in UTF-8.
WSL (Windows Subsystem for Linux) – A Windows feature that lets you run Linux distributions and tools (like base64) alongside PowerShell.
Related videos and Playlists:
• Active Directory Certificate Services (ADCS)
• Linux