Category filter
Script to adjust master volume on Windows devices
When used in public spaces like kiosks or shared workstations, it is required to set predefined audio levels for devices. IT admins may need to adjust the device volume to an optimum level, for instance, in smart classrooms and conference room digital signage installations. On Windows PCs, the user should modify the master volume to change all sounds. The volume for individual apps and system sounds can then be configured as a percentage of the master volume.
Admins can use the PowerShell script provided below to remotely modify the master volume on Windows devices with the help of Hexnode’s Execute Custom Script action.
Script to set the master volume
The following script installs a NuGet package with a minimum version of 2.8.5.201 without any user interaction.
Then the above script installs the AudioDeviceCmdlets module which consists of basic command lines of audio device controls with the help of NuGet package manager using PowerShell. It uses the playbackvolume parameter to set the device’s master volume to the desired value. Set the variable $preferredVolume to the necessary volume level. (Replace 42 with the required volume.)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
$preferredVolume = 42 try{ if(-not( Get-PackageProvider | Where-Object {$_.Name -eq "Nuget"})) { #installing nuget package if doesn't exists. Install-packageprovider -name Nuget -MinimumVersion 2.8.5.201 -Force } if (-not(Get-Module -ListAvailable | Where-Object {$_.Name -eq "AudioDeviceCmdlets"})) { #installing audiodevicecmdlets module Install-Module -name AudioDeviceCmdlets -Force } Set-AudioDevice -playbackvolume $preferredVolume Write-Host "Successfully configured", $preferredVolume } catch{ Write-Host $_.exception.message } |
Running this script will automatically adjust the device’s sound to the configured master volume. The user will still be able to change the volume level or disable sound from the device end.
To confirm whether the script has worked, you can check the Action History tab of the corresponding devices.