2024-11-08 12:38:20 +01:00
|
|
|
The *play-system-sounds.ps1* Script
|
|
|
|
===========================
|
2024-05-19 10:25:56 +02:00
|
|
|
|
|
|
|
play-system-sounds.ps1
|
|
|
|
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
```powershell
|
|
|
|
|
|
|
|
|
|
|
|
[<CommonParameters>]
|
|
|
|
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
|
|
|
|
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
|
|
|
|
```
|
|
|
|
|
|
|
|
Script Content
|
|
|
|
--------------
|
|
|
|
```powershell
|
|
|
|
<#
|
|
|
|
.SYNOPSIS
|
|
|
|
Plays all system sounds
|
|
|
|
.DESCRIPTION
|
|
|
|
This PowerShell script plays all operating system sounds.
|
|
|
|
.EXAMPLE
|
|
|
|
PS> ./play-system-sounds.ps1
|
|
|
|
(listen and enjoy)
|
|
|
|
.LINK
|
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
.NOTES
|
|
|
|
Author: Markus Fleschutz | License: CC0
|
|
|
|
#>
|
|
|
|
|
|
|
|
function PlaySoundFiles([string]$filePattern) {
|
|
|
|
$files = (Get-ChildItem "$filePattern")
|
|
|
|
foreach($file in $files) {
|
|
|
|
& "$PSScriptRoot/play-mp3.ps1" "$file"
|
|
|
|
Start-Sleep -milliseconds 500
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
if ($IsLinux -or $IsMacOS) { throw "Currently only supported for Windows" }
|
|
|
|
|
|
|
|
$WinDir = Resolve-Path "$env:WINDIR"
|
|
|
|
if (-not(Test-Path "$WinDir" -pathType container)) { throw "Windows directory at 📂$Path doesn't exist" }
|
|
|
|
|
|
|
|
Write-Host "`n Windows System Sounds at $WinDir\Media" -foregroundColor green
|
|
|
|
PlaySoundFiles "$WinDir\Media\*.wav"
|
|
|
|
PlaySoundFiles "$WinDir\Media\*\*.wav"
|
|
|
|
exit 0 # success
|
|
|
|
} catch {
|
|
|
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2024-11-20 11:52:20 +01:00
|
|
|
*(generated by convert-ps2md.ps1 as of 11/20/2024 11:51:59)*
|