Change Audio Output with Powershell in Windows 10

I have always wanted to change audio outputs in Windows 10 with a single key from my keyboard. I have a Steelseries Apex raw keyboard, which has a ton of macro keys, but there wasn’t a simple way to do it before. Not until I saw cdhunt’s WindowsAudioDevice-Powershell-Cmdlet. With this, I can simply create a one-line Powershell file for my Realtek Digital Output:

Set-AudioDevice -Index 3

Same goes for my Samsung TV and Acer monitor, which has inbuilt speakers. After this, I thought I was good to go, once I had set the script to one of my keyboard’s macro keys, but unfortunately Steelseries Engine 3 doesn’t support .ps1 files as executable macros. So, I had to turn to PS2EXE-GUI to turn my .ps1 files to .exe files. After this, I just had to point the macro key actions to right files and I was done.

Hopefully this helps someone else, who wants to do the same.

Tagged , , , , , , . Bookmark the permalink.

10 Responses to Change Audio Output with Powershell in Windows 10

  1. asdf says:

    I am a total noob. Can you explain this in grater detail please? does ‘AudioDevice’ need to refer to a specifi device and if so how to name it / where to find it?

    Thank you!

    • Ilkka says:

      Sure.

      First you download the necessary dll file: https://github.com/frgnca/AudioDeviceCmdlets/releases/download/v3.0/AudioDeviceCmdlets.dll

      Then you do the commands to import the module in powershell cmd:

      New-Item “$($profile | split-path)\Modules\AudioDeviceCmdlets” -Type directory -Force
      Copy-Item “C:\Path\to\AudioDeviceCmdlets.dll” “$($profile | split-path)\Modules\AudioDeviceCmdlets\AudioDeviceCmdlets.dll”
      Set-Location “$($profile | Split-Path)\Modules\AudioDeviceCmdlets”
      Get-ChildItem | Unblock-File
      Import-Module AudioDeviceCmdlets

      From here you can play around with the commands mentioned on https://github.com/frgnca/AudioDeviceCmdlets

      To get the list of audiodevices, you input “Get-AudioDevice -List” and from there you can see the ID numbers that you can use to change the audio device.

      • jk31 says:

        I am even more of a noob than the guy you responded to:

        When I type these commands, it says that the command “New-Item” is either typed wrongly or could not be found.
        Do I really type
        “New-Item “$($profile | split-path)\Modules\AudioDeviceCmdlets” -Type directory -Force”
        as written or do I need to exchange some parts of it?

  2. Gargwe Wdgwearg says:

    Thanks a lot! It’s exactly what I was looking for

    Regards

  3. D2G says:

    if you save and run as a script (.ps1) POSH needs permission even i you run posh with admin
    so enter this:
    set-executionpolicy remotesigned
    run saved script
    profitt

  4. Where would you save the DLL file to in Windows 10?

    • Ilkka says:

      I can’t remember where I saved it. I have formatted my computer few times after I wrote this. I don’t think the location matters that much, maybe the best place is where the script file is.

  5. Dave says:

    This is great! I’ve been looking for a way to quickly swap audio and this is perfect. I’m gonna write a ps script to toggle between my main speaker audio and my headset audio so I can have it setup to one key!

    • James says:

      You could always call the powershell.exe and pass your PS1 file as a paramater to it. That should allow you to call it as needed.

Leave a Reply