PowerShell Cookbook
This is an assorted collection of PowerShell snippets that I've used in the past and might need to use again.
Text functions
Convert CSV Table to Html
Get-Clipboard | ConvertFrom-Csv -Delimiter "`t" | ConvertTo-Html -Fragment | Set-Clipboard
Image functions
Convert-ImageToBase64
This converts a local picture into a base 64 string for the purposes of embedding in a <img>
tag
function Convert-ImageToBase4 ([string] $filepath) {
$imageBase64 = [Convert]::ToBase64String((Get-Content "$root\images\one-tile.png" -Encoding byte))
return "data:image/png;base64,$imageBase64"
}