Bart Simons

Bart Simons

Thoughts, stories and ideas.

Bart Simons




ps-spotify, a PowerShell module to control the Spotify Web API.

Bart SimonsBart Simons

In my previous article I demonstrated my dotnet core Spotify authentication 'gateway'. With your access and refresh tokens available, it is time to actually use them: for that, you need a client. You could choose to send raw API requests out to Spotify, but for the sake of 'why not?' I have created a PowerShell module that provides a front-end to the Spotify API - for example, you can use Find-SpotifyItem to search for a song, right from your command prompt or terminal. I have developed this module without any serious intentions, but it can actually be used in various situations:

  • Mute music if a specific window gets opened, resume when the window gets closed.
  • Mute music when a full-screen app gets opened (a video game for example).
Configuring ps-spotify

The file contains clear and updated instructions, covering the installation and configuration of ps-spotify on your system.

Before you get started, please remember to fill in your refresh token (you can get this token with the webapp discussed in my previous article) and basic bearer token (base64 encoded string of client id:client secret) in ps-spotify.psm1 - otherwise this module will not work! You can use this website to generate the base64 encoded string that is needed for the SpotifyBasicBearer.

ps-spotify setup

Good! Now we can finally use the module by importing it.

ps-spotify import module

If this shows no errors, you are ready and good to go.
I have written some examples below for demonstration purposes, feel free to try them out!

Getting the currently playing device (Get-SpotifyConnectDevice)


Setting the volume of the currently playing device (Set-SpotifyConnectVolume)


Play and pause Spotify

Set-SpotifyConnectPlay and Set-SpotifyConnectPause

Play "start me up"


I hope that my work and commitment on this project and other open-source projects is appreciated. Have a great day!

Bart Simons

Bart Simons