Registry Permissions for user
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio
This has to done in a offline mode, for XenDesktop with PVS; mount the VHD file from Disk Management and set the permissions.
Disable Microphone(s)
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Capture\{GUID}
DeviceState=10000001
DeviceState=4
Script to Disable all non Standard Microphone (Allow only Plantronics/HDX headsets)
$audioCaptureRegPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Capture" $systemNameVal = "{b3f8fa53-0004-438e-9003-51a46e139bfc},6" $MICS = Get-Item $audioCaptureRegPath $MICS.GetSubKeyNames() | % {` if($(Get-ItemProperty -Path $audioCaptureRegPath"\"$_).DeviceState -eq 1 ){` $systemNameData=$(Get-ItemProperty -Path $audioCaptureRegPath"\"$_\Properties).$systemNameVal if(!($systemNameData -match "plant") -or !($systemNameData -match "HDX")) { #The below throws access denied errors #Set-ItemProperty $audioCaptureRegPath"\"$_ -Name "DeviceState" -Value "4" #Alternative $tmpFileFullPath = [System.io.Path]::getTempFileName() "Windows Registry Editor Version 5.00" | Out-File -FilePath $tmpFileFullPath -Append " " | Out-File -FilePath $tmpFileFullPath -Append "[$($MICS.Name)\$_]" | Out-File -FilePath $tmpFileFullPath -Append #10000001 disables but makes it visible in GUI | 00000004 disables and prevents #it from being visible in Recording Devices GUI "`"DeviceState`"=dword:10000001" | Out-File -FilePath $tmpFileFullPath -Append " " | Out-File -FilePath $tmpFileFullPath -Append regedit.exe /S $tmpFileFullPath } } }
Each GUID will be different. How do you generalize it, to figure out each systems Audio GUID ? I need to script out for a VM to automatically set the microphone of that VM (Desktop) to be default.
Kyle,
that can be achieved by enumerating the following reg for MIC and Speakers respectively
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Capture
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Render
from the script above $systemNameVal holds the PKEY_Device_FriendlyName which is the audio device friendly name that is seen from the windows audio GUI.
I go through each guid and disable the devices that do not match the friendly name i need using DeviceState reg value. this will automatically make the preferred device to be the only default.
DeviceState=0x10000004 hides it from the gui
DeviceState=0x00000004 sets as disabled.
DeviceState=0x00000001 sets as available
Since my script only makes one device as available, that devices will automatically become default.
Note: Plantronics is the audio device friendly name I used to demonstrate in the post.
Hope this makes it clear.
-Siva
Siva-
Thanks for your reply. I tried to download your script, but the archive was corrupt. Can I get a copy still ?
Thanks,
Kyle
Sure,
Thanks for pointing that out.
http://www.eng.utoledo.edu/~smulpuru/Scripts/Disable-Microphone.zip
-Siva
Thanks Siva. Im new to powershell, so I will have to play around with this to do what I need it to do.
Just wanted to point out that I couldn’t get it to work initially but after I fiddled around with it I noticed that there was a typo in the script.
“[$($MIC.Name)\$_]” | Out-File -FilePath $tmpFileFullPath -Append
should be
“[$($MICS.Name)\$_]” | Out-File -FilePath $tmpFileFullPath -Append
After changing to that the script worked.
Thanks E H