Skip to content

Instantly share code, notes, and snippets.

@hobelinm
Last active August 29, 2015 13:57
Show Gist options
  • Save hobelinm/9443380 to your computer and use it in GitHub Desktop.
Save hobelinm/9443380 to your computer and use it in GitHub Desktop.
A simple animated Write-Progress sample made in PowerShell
$xMessage = @()
$xMessage += " --------------# | \\ // |# | \\// |# | //\\ |# | // \\ |# --------------".Replace( `
"#", (" " * ($host.UI.RawUI.BufferSize.Width - 16 - 4)) )
$xMessage += " ----------------# | \\ // |# | \\ // |# | // \\ |# | // \\ |# ----------------".Replace( `
"#", (" " * ($host.UI.RawUI.BufferSize.Width - 17 - 4)))
$chgIdx = 0
$index = 0
while($true)
{
Write-Progress -Activity "My Activity" `
-Status "My Status" `
-PercentComplete (($index++) % 100) `
-CurrentOperation $xMessage[($index % 2)]
Start-Sleep -Milliseconds 200
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment