How do I get notified when a command is finished and Powershell is back to prompt?

Viewed 291

I'm doing some testing job, and a part of it is to regularly write files to some hardware. The thing is, the write can take as short as 20 seconds, or as long as several minutes. Staring at the screen and waiting for it to be done is a huge waste of time, so I'm wondering if there is a way to get notified (like making a beep sound by using [console]::beep() ) when the command is done and the Powershell is back to prompt?

2 Answers

You can edit your prompt function:

$function:prompt = @"
{0}
[console]::beep()
"@ -f $function:prompt.ToString()

A more concise version (compliments of mklement0) if you don't mind semi-colon delimited commands:

$function:prompt = "$function:prompt; [console]::beep()"

PowerShell Alert when command is finished :

"Answer" | out-file response.txt
[console]::beep(500,300)

Powershell > [console]::beep for 1-Minute :

[console]::beep(500,60000)

Also - Try using the "Asterisk" Alert :

[System.Media.SystemSounds]::Asterisk.Play()
Related