Play a WAV File With SoundPlayer

Play a Windows WAV sound from a script, synchronously or asynchronously.

WindowsaudiosoundpowershellLow risk
Run the snippet to play a system WAV file.

01Command

Command
$ (New-Object System.Media.SoundPlayer "C:\Windows\Media\Alarm01.wav").PlaySync()

02What it does

System.Media.SoundPlayer loads and plays uncompressed WAV files. PlaySync blocks until playback ends, which is ideal at the end of a build script, while Play runs asynchronously. Point it at any WAV path, such as one under C:\Windows\Media.

03Risk

RiskLow risk
RequirementsWindows 10/11 with PowerShell 5.1 or PowerShell 7+
!Warning: Only WAV files are supported; MP3 and other formats need a different player or the Windows Media libraries.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • SoundPlayer Class
    Microsoft Learn · vendor-doc · 2026-09-20
    Evidence: Plays .wav files; PlaySync blocks until the sound finishes.

Last verified: 2026-09-20 · Category: Media

06Related solutions