PowerTip: Display a Blinking Message by Using PowerShell

Summary: Use this one-line Windows PowerShell command to display a blinking message.

Hey, Scripting Guy! Question Is there a one-line command that I could use to blink a message in the Windows PowerShell console to get the users attention?

Hey, Scripting Guy! Answer Pipe a range of numbers to the Foreach-Object cmdlet (% is an alias), clear the screen in the Begin block,
          and then display the message, pause, clear the screen, and pause in the Process block:

1..3 | % -begin {cls} -process {"hello";sleep 1;cls;sleep 1}

Comments (4)

Cancel reply

  1. Aakash Shah says:

    What if want the rest of the screen to stay intact, but we only want a specific line in the window to blink (let’s say it’s the last line) – is there a way to do this?


  2. Anonymous says:

    so much cool stuff its amazing

  3. Craig Schreiner says:

    This is really dorky because this isn’t truly a blinking message that I would want to use, but rather a simulated blinking message:

    1..3 | % -begin {$msg = "hello"} -process {write-host -nonewline "`r$msg";sleep 1;write-host -nonewline ("`r" + (" " * $msg.Length));sleep 1}

Skip to main content