Share via


Using BEEP sound in PowerShell Scripts

After watching the Valentine post of “Jeffery Hicks” I started playing with $([char]) characters. And while working with these characters I found a great character that is character 7.

http://lh5.ggpht.com/-KHt4Z35XXp4/T0Xf8XyWHuI/AAAAAAAACVs/7rFnJl1paWA/23-02-2012%25252012-07-13_thumb%25255B1%25255D.png?imgmax=800

So what is interesting in character number 7? It is a Beep Sound. For example, if in your script you are rebooting the server or laptop, you can provide 3 beeps for rebooting. Or  we can  set a beep after every task or command finished his task.

Cool isn’t..

Try this script.
Download Script from Here: http://dl.dropbox.com/u/17858935/Beep.zip
#### save it as beep.ps1 or so....

Write-Host "I am going to reboot the Laptop after 3 Beep" -ForegroundColor Red

$([char]7)

write-Host "Beep 1 " -ForegroundColor Green

sleep 1

$([char]7)

write-Host "Beep 2 " -ForegroundColor Green

sleep 1

$([char]7)

write-Host "Beep 3 " -ForegroundColor Green

sleep 1

Write-Host "`n"

Restart-Computer -Force -WhatIf

#################################
and the output is like below. Our computer is going to reboot after 3 beeps... 
http://lh6.ggpht.com/-PLE-heS0tYM/T0Xf-7bNmmI/AAAAAAAACV8/wU0sEGHYxak/23-02-2012%25252012-09-26_thumb%25255B1%25255D.png?imgmax=800 
Download Script from Here: http://dl.dropbox.com/u/17858935/Beep.zip 

Note: You can also use `a to beep  and make sure that you enclosed it in double quotes like "`a" :)

Thanks for reading,
Aman Dhally