In the previous tip we explained how PowerShell can play system sounds. For a bit more flexibility, PowerShell can also play arbitrary *.wav sound files:
$soundPlayer = New-Object System.Media.SoundPlayer $soundPlayer.SoundLocation="$env:windirMedianotify.wav" $soundPlayer.Play()
By default, PowerShell does not wait for the sound to be played. If you’d like to play it synchronously, try this:
$soundPlayer = New-Object System.Media.SoundPlayer $soundPlayer.SoundLocation="$env:windirMedianotify.wav" $soundPlayer.PlaySync() "Done."
To play a different sound file, simply replace the path to the sound file.
The sound player can also play the sound file in a loop, using a background thread:
$soundPlayer = New-Object System.Media.SoundPlayer $soundPlayer.SoundLocation="$env:windirMedianotify.wav" $soundPlayer.PlayLooping()
When you do this, make sure you stop the sound again:
Do you know PowerShell Conference EU 2018, taking place April 17-20 in Hanover, Germany? If you are an advanced PowerShell professional, you shouldn’t miss this year’s agenda: www.psconf.eu: Hover over a session to view its abstract.
With 45 international top speakers including PowerShell inventor Jeffrey Snover, 80 sessions, and workshops, this event is much more than just a conference. It is a one-of-a-kind Advanced PowerShell Training and a very unique opportunity to meet friendly PowerShell gurus, get authoritative answers to even the trickiest PowerShell questions, and bring home fresh ideas.
This conference is not profit-driven, and all speakers volunteer. The delegate fee basically covers venue, food and drinks throughout the conference, evening events with grand dinner, and workshops.
Just don’t wait too long: this unique event is limited to 300 delegates, with 265 seats already taken by the time of this writing. Visit http://www.powershellmagazine.com/2018/02/09/powershell-conference-eu-2018/ for more details, or www.powershell.love for a quick impression of last year.