Disable/Filter Microphone(s) in Windows 7 VDI via Registry

Registry Permissions for user


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)




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"
    $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

Download Script


Join the Conversation


  1. 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.

  2. Kyle,
    that can be achieved by enumerating the following reg for MIC and Speakers respectively
    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.

  3. Thanks Siva. Im new to powershell, so I will have to play around with this to do what I need it to do.

  4. 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.

Leave a comment

Your email address will not be published. Required fields are marked *

WordPress Appliance - Powered by TurnKey Linux