Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

powershell

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?

like image 887
Yunc5 Avatar asked Oct 18 '25 14:10

Yunc5


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()"
like image 131
AdminOfThings Avatar answered Oct 20 '25 12:10

AdminOfThings


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()
like image 28
חִידָה Avatar answered Oct 20 '25 13:10

חִידָה



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!