A PowerShell script that guards and maintains your microphone's volume at a specified level. This is useful when certain applications or system events unexpectedly change your microphone volume.
- Automatically restores volume to desired level when changes are detected
- Includes WhatIf support for testing
- Windows PowerShell or PowerShell Core
- AudioDeviceCmdlets PowerShell module (automatically installed if missing)
- Clone this repository or download the script:
git clone https://github.com/Vortiago/MicrophoneLevelGuard.git- Navigate to the script directory:
cd MicrophoneLevelGuardRun the script with default settings (maintains current volume level):
.\MicrophoneLevelGuard.ps1Set a specific volume level (e.g., 75%):
.\MicrophoneLevelGuard.ps1 -DefaultVolume 75Set interval delay (e.g., 1000ms):
.\MicrophoneLevelGuard.ps1 -Interval 1000Show detailed progress with verbose logging:
.\MicrophoneLevelGuard.ps1 -DefaultVolume 50 -VerbosePreview changes without applying them:
.\MicrophoneLevelGuard.ps1 -DefaultVolume 80 -WhatIfView help and usage information:
.\MicrophoneLevelGuard.ps1 -Help-DefaultVolume <0-100>: Sets the target volume level (0-100%). If not specified, uses current volume.-Interval <ms>: Sets the loop interval in miliseconds. Default to 500ms-Help: Shows the help message with usage instructions.-Verbose: Shows detailed progress messages.-WhatIf: Shows what changes would be made without actually making them.
The script runs in a continuous loop, checking the microphone volume every 500 milliseconds (or specified by the user). If it detects that the volume has changed from the specified level, it automatically restores it to the desired value.
When started, it displays a list of all available input devices, highlighting the current default device. The script will continue running until interrupted with Ctrl+C.
- Open Windows Task Manager
- Go to Action -> Import Task
- Import the file Microphone_100%.xml (Before importing, update the
-Fileargument in the XML file to the directory where you have stored the MicrophoneLevelGuard.ps1 file in your computer) - Select the option Run whether user is logged on or not (avoid console popping up)
- Check the Do not store password. The task will only have access to local computer resources. checkbox
- Press OK.
If you encounter permission issues, try running PowerShell as Administrator.
Common issues:
- "Module not found" - The script will attempt to install the required module automatically
- "Access denied" - Run PowerShell with administrative privileges
- "No microphone detected" - Ensure your microphone is properly connected and recognized by Windows
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.