Using PowerShell on your Stream Deck

An excellent way to run your scripts is by using a Stream Deck 🙂 I purchased one last month (Elgato Stream Deck Mk 2 Studio Controller with 15 buttons), mainly because of the Microsoft Teams support, but you can use it for PowerShell too! In this blog post, I will show you a few examples.

What is a Stream Deck?

“THE ELGATO STREAM Deck—not to be confused with Valve’s Steam Deck—is an incredibly popular tool for Twitch streamers. It lets you automate basic tasks—like switching scenes and going live—but that same platform is useful even if you don’t play games for an audience.”

source: https://www.wired.com/story/elgato-stream-deck-productivity-tips/

What does a Stream Deck look like?

Well… It’s a small device that you can connect using USB to your computer, its dimensions are ‎ 8.4 x 11.8 x 2.5 cm, and it weighs 145 grams. This is the version that I’m using right now, it has 15 buttons, but you can also get a 32-button one!

Why should you use it?

If you like the ease of starting programs, changing volume settings, or turning off/on lights with a press of a button… Then this is something for you 🙂 My starting page looks like this:

From left to right and top to bottom:

  • The current temperature of my Nest Thermostat
  • Toggle the switch to switch temperature to 21 when pressed once or to 19 when you hold it for two seconds
  • Play/Pause any video or audio stream that’s active
  • Start Visual Studio Code
  • Start Windows Terminal
  • Mute/Unmute Microphone
  • Mute
  • Volume Down
  • Volume Up
  • Weather temperature outside
  • Start Spotify Chill Music Lab playlist (https://open.spotify.com/playlist/3RbOwxPNPVuAKyerAWuZVD?si=13438a341dc546b1)
  • Previous number
  • Next number
  • Sub menu for my lights
  • Next Page

On my second page, I have my Teams icons:

Very handy when in a Teams meeting! To use this, you must retrieve the API key from your Teams client in the Settings, Privacy menu in the Manage API section.

Note: The API key is not available yet in the New Teams / Preview version 🙁

Using PowerShell on a Stream Deck

Scripts

I use the Windows ScriptDesk plugin for starting scripts, and you can install this using the Built-In Stream Deck Store. After installing it, you will see these options appear in the right pane:

Drag-and-Drop it to the profile overview on the button’s location that you want to program. In this example, I will program a button to start a script that stops all Google Chrome processes.

  • Enter “Kill Chrome” as the title.
  • Enter “Get-Process -Name Chrome | Stop-Process -Force:$true -Confirm:$false” as the action that should be run when the button is pressed

This should look like this now:

When pressing the button, you won’t see any progress windows, and all running Chrome processes will be killed. You can also use other commands from the buttons on the right, like the Start-Proces to start a program or the URL script that will open all URLs returned from your script. (You could use that to read a set of favorite URLs and let the button launch them all in your browser.)

Note: There is no option to run a script with elevated / Administrator permissions!

Visual Studio Code

There’s also Stream Deck support in Visual Studio code! You must install the “Stream Deck for Visual Studio Code” from Nicollas R to enable it inside VSCode and install “Visual Studio Code” developer tools from the Stream Deck Store to enable it in Stream Deck.

After installation, these buttons should appear in your Stream Deck app.

In the example below, I configured a button to format the current script inside Visual Studio Code. You can look up the correct Command ID by going To File, Preferences, Keyboard Shortcuts, and typing the action in the search bar. Right-click the desired command and select Copy Command ID.

Drag the Execute Command action to your Stream Deck, select it, and paste the command you copied into the Command (ID) line. If you now press that button in a script, it will format the script for you.

You can program almost every action in a button, which is very powerful and handy if you typically have to press multiple buttons or navigate through a few menus. You can also use the Open Folder action to switch to a folder in Visual Studio Code or Execute Terminal Command to run a specific command line.

Note: These buttons only work when Visual Studio Code is running

It’s all about your creativity!

You can program many buttons and actions to help you with your workflows. There are loads of possibilities, and once you get used to running them from the Stream Deck… You will take that everywhere with you 🙂

2 thoughts on “Using PowerShell on your Stream Deck

  1. Great stuff. Thanks for this information. Is it possible to use stream deck to copy and paste a windows text file. Or replace a certain txt file with another

    • You could try a Multi-Action button in which you do CTRL-C (Hotkey), System: Open and specify a text file to open, CTRL-End (Hotkey), Enter (Hotkey) and CTRL-V to copy the selected text to the end of a existing textfile. Replace is something that you can do as well like that I guess, perhaps you do need to put some sleep/wait command to give your system some time before continuing to the next command

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.