Functions/Set-SpeakerVolume.ps1
|
function Set-SpeakerVolume { <# .Notes AUTHOR: Skyler Hart CREATED: Sometime before 2017-08-07 LASTEDIT: 08/18/2017 20:47:06 KEYWORDS: .LINK https://wanderingstag.github.io #> [CmdletBinding()] [Alias('Volume')] Param ( [switch]$min, [switch]$max, [int32]$volume = "10", [switch]$mute ) $volume = ($volume/2) $wshShell = new-object -com wscript.shell If ($min) {1..50 | ForEach-Object {$wshShell.SendKeys([char]174)}} ElseIf ($max) {1..50 | ForEach-Object {$wshShell.SendKeys([char]175)}} elseif ($mute) {$wshShell.SendKeys([char]173)}#turns sound on or off dependent on what it was before elseif ($volume) {1..50 | ForEach-Object {$wshShell.SendKeys([char]174)};1..$Volume | ForEach-Object {$wshShell.SendKeys([char]175)}} } |