Add-Type -AssemblyName presentationCore

$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$soundsFolder = Join-Path $scriptDir "sounds"

$wshell = New-Object -ComObject WScript.Shell

while ($true) {

    # random wait between 10 seconds and 5 minutes
    $wait = Get-Random -Minimum 10 -Maximum 300
    Start-Sleep -Seconds $wait

    # force volume to max for 5 seconds
    $end = (Get-Date).AddSeconds(5)

    while ((Get-Date) -lt $end) {
        $wshell.SendKeys([char]175)
    }

    # get all mp3 files
    $files = Get-ChildItem $soundsFolder -Filter *.mp3

    if ($files.Count -gt 0) {

        # pick random sound
        $randomSound = Get-Random $files

        # play sound
        $player = New-Object System.Windows.Media.MediaPlayer
        $player.Open([Uri]$randomSound.FullName)
        $player.Play()

        Write-Host "Playing $($randomSound.Name)"
    }
}