PowerTip: Use PowerShell to Send Beep to Console

PowerTip: Use PowerShell to Send Beep to Console

  • Comments 9
  • Likes

Summary: Use the Beep command in Windows PowerShell.

Hey, Scripting Guy! Question How can I send a sound in Windows PowerShell to notify a user if an error occurs in the script?

Hey, Scripting Guy! Answer Windows PowerShell can send a Beep to the console:


Change the value of the first number to alter the pitch (anything lower than 190 or higher than 8500 can’t be heard), and change the value of the second number to alter the duration:


Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Old much?

    Even my 55 year old ears can hear down to 50, anything lower has a beat for some reason.

    Actually, I just got this error playing with ranges.

    Exception calling "Beep" with "2" argument(s): "Console.Beep's frequency must be between 37 and 32767.

    I tried using 35. :/

    And again, I could hear 37, it just had a clicking beat to it.  Hardware?  Software?  Logitech USB headphones with mic.

    And my upper range of which I can just barely hear is 12500.  And I know I'm losing my hearing.  Above 20000 is the real limit of a newborn kid.  I'll take my 12500.

  • @Bryan

    You have two possible causes:

    1. You need a new hearing aid.

    2. Harmonic interference.

    For a description of how and why this happens see:  bolvan.ph.utexas.edu/.../interference.pdf

  • I knew I had seen some good PowerShell music somewhere before.  It turns out that Lee Holmes is a musician and has "instrumented" PowerShell for basic MIDI capabilities - all in about 88 lines of script.


  • Actually, there's an even simpler method for a system beep. Get back to your DOS roots!

    PS C:\> echo ^G

    For "^G", press CTRL+G. Not very configurable, but short and sweet.

  • Sweet, I can hear from 47 up to 13,200.  After years of loud guitars, motorcycles and guns I'm surprised I can hear at all!

    /off to torture coworkers

  • You could combine this with a looping Test-Connection -count 1. When a computer responds back to a ping, play a note of a certain frequency. When the computer doesn't respond, play a different frequency, or shorten the duration down to just a ticking.

    This would be a way of keeping an ear on a computer reboot. You can reboot a server, then move on to other things, and you'll know right away when the server is back online.

  • I'm sure this can be improved, but here's my attempt to monitor network pings by sonar:

    $Server = Read-Host "Enter server name to monitor by sonar"

    $x = 0

    Write-Host "Pinging $Server by sonar . . . "

    Write-Host "(Press Ctrl-C to break out of sonar loop.)"


    { $x = $x + 1

    if (Test-Connection -count 1 -quiet -computer $Server)



    Start-Sleep -s 2





    $x = $x + 1




    ($x = 0)

  • <##Super Mario Intro ##>

    $i = 1

    do {Write-Host $i; $i++

    [console]::beep(659,250) ##E

    [console]::beep(659,250) ##E

    [console]::beep(659,300) ##E

    [console]::beep(523,250) ##C

    [console]::beep(659,250) ##E

    [console]::beep(784,300) ##G

    [console]::beep(392,300) ##g

    [console]::beep(523,275) ## C

    [console]::beep(392,275) ##g

    [console]::beep(330,275) ##e

    [console]::beep(440,250) ##a

    [console]::beep(494,250) ##b

    [console]::beep(466,275) ##a#

    [console]::beep(440,275) ##a

    [console]::beep(392,275) ##g

    [console]::beep(659,250) ##E

    [console]::beep(784,250) ## G

    [console]::beep(880,275) ## A

    [console]::beep(698,275) ## F

    [console]::beep(784,225) ## G

    [console]::beep(659,250) ## E

    [console]::beep(523,250) ## C

    [console]::beep(587,225) ## D

    [console]::beep(494,225) ## B


    until ($i -gt 1)

  • @Matthew Kerfoot That is too funny ... good job.