How to capture (record) microphone input

I’m working on a script, to go and unmute the speaks on a local or remote computer, send a message using [Speech] Class
I’ll show you the code below. But I was wondering if it’s possible to use PowerShell to capture a (Record) Microphone input ??

Set Speaker function

Function Set-Speaker($Volume) {
$wshShell = new-object -com wscript.shell;1…50 | % {$wshShell.SendKeys([char]174)};1…$Volume | %{$wshShell.SendKeys([char]175)}}
Set-Speaker -Volume 50

Invoke-Command -ComputerName $PC -scriptblock {

            Add-Type -AssemblyName System.speech
            $talker = New-Object System.Speech.Synthesis.SpeechSynthesizer
            $talker.speak("Hi there .. Your your password expires today. Please change your password now")

}

So, because I know there’s no PowerShell command for this, I searched “.NET record microphone”. You might try that - there are some good examples. You’re going to need to translate from C# or VB, because you’re basically going to be coding .NET.

FWIW, I also searched “.net set volume” and got some good results, which might give you something more reliable than that SendKeys approach you’re using. That’s almost 20 years old and isn’t going to be reliable across a lot of different systems.

You’re correct. I tried to invoke the SendKeys didn’t work on all of the AD machines.
Instead I used “InteropServices”; interface “IAudioEndpointVolume” and It works :slight_smile:

As for Mic. I found some good C# examples …