Hey everyone! I'm trying to find a way to prevent a specific audio device from being selected by any applications on Windows 11, similar to how you can do it manually by going to Settings > Sound > device > Properties and clicking on 'Not Allow'. I've tried using a couple of scripts:
1. By device name, like this:
```powershell
Get-PnpDevice -PresentOnly -Class AudioEndpoint | Where-Object Name -Match 'Speaker' | Disable-PnpDevice -Confirm:$false
```
2. By instance ID:
```powershell
Disable-PnpDevice -InstanceId "SWD\MMDEVAPI\{0.0.0.00000000}.{547105DA-B875-477F-AB9B-24B6B2D68E95}" -Confirm:$false
```
Both methods successfully disable the device in Device Manager, but the device can still be selected by apps. I'm looking for a script that can achieve the same effect as clicking 'Not Allow' in the properties menu. Any advice would be much appreciated! Thanks!
2 Answers
You might want to try using this module: [AudioDeviceCmdlets](https://github.com/frgnca/AudioDeviceCmdlets/tree/master). However, just a heads up, it might not have the exact enable/disable feature you're looking for, but it's worth checking out!
You might want to check out Nirsoft's SoundVolumeView. It lets you disable audio devices with a command like:
```plaintext
SoundVolumeView.exe /Disable Speakers
```
You could even set this up through Task Scheduler to run whenever the device is connected, or at intervals. I've had success using it to manage webcam microphones; it's a handy tool!
This did the trick! Thanks a bunch! 🙂
Upvote for Nirsoft! I used their tools at my old job for managing demo computers. The native options in Windows can get really complicated, but their command-line utilities are straightforward and effective.
Doesn't seem to have an enable/disable feature, but thanks anyway! 🙂