Suggest a feature
Added: Jun 30, 2018 12:30 AM
Note that this script will only work with PowerShell 5.1, not PowerShell Core (i.e. PowerShell 6.0), because the necessary dependencies for this to work were nixed in favor of cross-platform functionality for 6.0.
$WAVPlayer = New-Object System.Media.SoundPlayer
$WAVPlayer.SoundLocation = "C: \File\Location.wav"
$WAVPlayer.PlaySync ( )
# Note that this will play the entire song, so to kill the process, I've actually been having to open a new pwsh window and use:
# This will list the process id, which I then kill like this:
-Id < id >
# Note that I don't simply do Get-Process powershell | Stop-Process because I may have
# multiple powershell windows open and I want to close only the one which is refusing to
# do anything besides play my .wav file