Behind the PowerShell Pipeline logo

Behind the PowerShell Pipeline

Subscribe
Archives
August 7, 2024

Creating ANSI Progress Bars in PowerShell

Let's wrap up our exploration of ANSI alternatives and look at one last item. In the previous article in this series, I shared some code you could use to create spinner-type progress bars using ANSI escape sequences or even emojis.

$monkeys = @(
    [char]::ConvertFromUtf32(0x1f435),
    [char]::ConvertFromUtf32(0x1f648),
    [char]::ConvertFromUtf32(0x1f649),
    [char]::ConvertFromUtf32(0x1f64a)
)1..10 | ForEach-Object {
    $monkeys | ForEach-Object {
        #using ANSI formatting
        Write-Host "e[1Ae[2K$_ e[3;38;5;190mWorking....e[0m"
        Start-Sleep -Milliseconds 250
    }
} -End {
    Write-Host "e[1Ae[2K"
}

You could use this as an alternative to Write-Progress. However, you could also create a custom progress bar solution using PowerShell and ANSI. This will be for special use cases and there's no one-size-fits-all solution. You'll need to take the techniques and concepts and adapt them to your specific needs. Let's dig in.

Want to read the full issue?
GitHub Bluesky LinkedIn About Jeff
This email brought to you by Buttondown, the easiest way to start and grow your newsletter.