Fun With Alerts (“`a”)

I just decided to restart Outlook to see if that made some weirdness I was experiencing go away.  As you may or may not know, the Outlook process often is running for quite a bit after the Outlook window goes away.  As such, you really don’t want to start another instance of Outlook until the first version is done. 

In V2, we now have the WAIT-PROCESS command so what I wanted to do was:

PS> Wait-Process Outlook; Outlook

The problem with that is that Outlook is not in the Path so it doesn’t work.  I could go figure out how to do this but I didn’t want to spend the time right now so instead I did the following:

PS> Wait-Process Outlook; “`a”

What that does is wait for the process to end and then emit an “Alert” (same as BEEP).  I waited for the alert and then knew it was safe to restart Outlook.  Anyway – I don’t know how many people know about Alert so I thought I would blog it. 

If you read the help on About_Quoting_Rules, you see a list of  the following special characters are recognized by Windows PowerShell:

    `0    Null
    `a    Alert
    `b    Backspace
    `f    Form feed
    `n    New line
    `r    Carriage return
    `t    Horizontal tab
    `v    Vertical tab

 

Experiment!  Enjoy!  Engage!

Jeffrey Snover [MSFT]
Distinguished Engineer
Visit the Windows PowerShell Team blog at:    http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at:  http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx