frgnca / AudioDeviceCmdlets

AudioDeviceCmdlets is a suite of PowerShell Cmdlets to control audio devices on Windows
MIT License
737 stars 92 forks source link

Get-AudioDevice -Playback output is wrong sometimes in scripts #54

Closed Nama closed 2 years ago

Nama commented 2 years ago

Hi, I'm using your Cmdlet in a script to determine if the monitors should be turned off or the screensaver should start.

While the terminal output is always correct, the script gets another return from the Cmdlet.

I tried running the script with Powershell, but generally I'm using Powershell Core. Same on both. The "TV" sound device is an AVR, which is not always turned on (so it vanishes from the playback devices list in Windows). A guess is, that this is causing the issue.

Headset Opt (High Definition Audio Device) is most of the time the only other enabled playback device and it is not even the communication default. There are also no enabled recording devices (empty list, except for disabled devices).

Terminal:

> Get-AudioDevice -Playback | Select-Object -Property Name

Name
----
TV (NVIDIA High Definition Audio)

Script debug output:

IdleTarget: 360
HDMIAudioDevice: TV (NVIDIA High Definition Audio)                 <- The sound device to check for
Dynamic Values:
IdleSeconds: 364.7178016
DefaultSoundDevice: Headset Opt (High Definition Audio Device)     <- Cmdlet output
LockedScreen: 
ActiveDisplay: Keine.

Monitor off - No HDMI Audio
Nama commented 2 years ago

Seems to have been an error with the script. Works now correctly, sorry...