# Copyright © 2015, Microsoft Corporation. All rights reserved. # :: ======================================================= :: <# DESCRIPTION TS_LowVolume validates whether the selected audio device is set to low volume. ARGUMENTS deviceType : Contains string value of specific Audio device type selected. deviceID : Contains string value of specific Audio device ID selected. RETURNS result : Boolean value $true if audio volume is low else $false #> #==================================================================================== # Initialize #==================================================================================== PARAM($deviceType, $deviceID) Import-LocalizedData -BindingVariable localizationString -FileName CL_LocalizationData #==================================================================================== # Load Common Library #==================================================================================== . .\CL_AudioDiagnosticSnapIn.ps1 . .\CL_Utility.ps1 #==================================================================================== # Main #==================================================================================== [bool]$result = $false [bool]$detected = $false [int]$currentVolume = -1 Write-DiagProgress -Activity $localizationString.lowVolume_progress try { Register-AudioDiagnosticSnapIn $device = Get-AudioDevice -id "$deviceID" if($device.State -eq 1) { $currentVolume = $device.MasterVolume $result = (($currentVolume -le 10) -and ($currentVolume -gt -1)) } if([String]::IsNullOrEmpty($deviceType)) { $device | Select-Object -Property @{Name=$localizationString.currentVolume;Expression={[string]($_.MasterVolume) + "%"}} | ConvertTo-Xml | Update-DiagReport -id CurrentVolumeLevel -name $localizationString.CurrentVolumeLevel_name -description (($localizationString.CurrentVolumeLevel_description) -f (Get-DeviceName $deviceType)) -Verbosity Informational -rid "RC_LowVolume" } if($result) { $detected = $true Write-DiagProgress -Activity " " Update-DiagRootCause -id 'RC_LowVolume' -Detected $detected -Parameter @{'DeviceType' = $deviceType; 'DeviceID' = $deviceID; 'Volume' = $currentVolume} } } Catch { $errorMsg = $_.Exception.Message $errorMsg | ConvertTo-Xml | Update-DiagReport -Id "TS_LowVolume" -Name "TS_LowVolume" -Verbosity Debug } finally { Unregister-AudioDiagnosticSnapIn } return $detected