Skip to content

Instantly share code, notes, and snippets.

@PrateekKumarSingh
Created October 21, 2016 11:08
Show Gist options
  • Select an option

  • Save PrateekKumarSingh/3c816beb274a2055c09b2337d376d489 to your computer and use it in GitHub Desktop.

Select an option

Save PrateekKumarSingh/3c816beb274a2055c09b2337d376d489 to your computer and use it in GitHub Desktop.
function ScrollOnPromptUntil($UntilDateTime, $prePromptMsg, $postPromptMsg, $postPromptMsgOnNextLine)
{
$scroll = "/-\|/-\|"
$idx = 0
Write-Host $prePromptMsg -NoNewline
$origpos = $host.UI.RawUI.CursorPosition
do
{
$host.UI.RawUI.CursorPosition = $origpos
Write-Host $scroll[$idx] -NoNewline
$idx++
if ($idx -ge $scroll.Length)
{
$idx = 0
}
Start-Sleep -Milliseconds 100
} until ((Get-Date) -ge (Get-Date $UntilDateTime))
Write-Host "`b$postPromptMsg`r" -NoNewline
# It's over - clear the activity indicator.
$origpos.X = 0
if ($postPromptMsgOnNextLine -eq $true) {
$origpos.Y += 1
}
$host.UI.RawUI.CursorPosition = $origpos
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment