/* ]]> */
Nov 162009
 

This is a really simple but possibly worthwhile thing to know about. Let’s say you have a long running command or script and (like me) you’re juggling about 25 other Windows besides your PowerShell session. You can easily set up an alert mechanism to let you know that your script has complete with this one simple line of code:

?View Code POWERSHELL
write-host `a

This will cause a (rather loud) beep sound to occur (like computers used to make back before they had sound cards).

Possible places to use this in your code is upon script/command completion or when an error occurs. You could also add this command to execute right after a script as follows:

?View Code POWERSHELL
./myscript; write-host `a

Add more beeps if you like:

?View Code POWERSHELL
./myscript; write-host `a`a`a

Note: Be sure to use the single back-quote character (a regular single quote will not work).

 Posted by at 10:12 am

  2 Responses to “Add a “BEEP” to your PowerShell script”

  1. This doesn’t work if the system’s PC SPEAKER is not working.

  2. True that!
    Good Point Cory.

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Page optimized by WP Minify WordPress Plugin