Play Sounds and Music with PowerShell

In the mood for some music while working on your windows machines ? Use PowerShell to play your favorite songs with NET classes.

Here’s a code sample you can build on.

Line 1 and 2 plays beeps. Line 4 and 5 plays windows built-in notifications. Last but not least I use the media player to play every song you want in looping mode. To stop the music, I use the stop method of the object.



$player = New-Object System.Media.SoundPlayer "$env:windir\Media\windows logon.wav"

Enjoy your favorite songs!

Categories: PowerShell

Tagged as: ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.