Run the CLI for Microsoft 365 with PowerToys Run

Run the CLI for Microsoft 365 with PowerToys Run header image

While wrapping up the year 2022 I found some time going through my last to-dos. One of them being diving a bit more into PowerToys. I have been using Power Toys for a while now, but never got around playing with the PowerToys Run. I use it, but never figured out if I could run some more complex tasks from the experience. As it turns out you can!

Power Toys Run and CLI for Microsoft 365

Power Toys Run works as a quick launcher and allows you to execute tasks. There are a few pre installed plugins and you have a few options. The thing I wanted to play around with is to execute quick actions with the CLI for Microsoft 365. In my development cycle I quite often find my self quickly creating stuff for demo purposes. Or just getting some additional details. Any step I can take to streamline that process will shave of a few minutes so would be a good thing.

Starting the launcher is easy, by default configured to alt + space. Using that combo you can start programs and use different action keys. So using running PowerShell you can start your terminal, or use Visual Studio Code you can start your development experience.

It also allows you to pass Program Parameters. So my first try was to run PowerShell -- m365 status to see if I could run CLI commands. Turns out you can 🔥. The only downside is that once the command is it automatically closes your window. But since any program you start supports command line parameters all that was needed was to figure out what PowerShell or Windows Terminal Supports.

To check that just start your terminal run PowerShell -help to get the available command line parameters. Since there is a -NoExit option you can pass that when executing commands. So running powershell -NoExit m365 status would return my current logged in connection and wouldn’t close my Terminal Window.

With that in place I can now quickly run commands and get the results I am looking for. Things like listing all teams to see if a Team was created now saves me a click of opening my Terminal. With alt + space and PowerShell -NoExit m365 teams team list all is done.

PowerToys run and CLI for Microsoft 365

Since the CLI for Microsoft 365 is also working on App Commands that leverage the a .m365rc.json file to store information we can use those commands from your PowerToys Run to quickly assign or remove permissions in your development cycle without the need to start them directly form your VSCode terminal.

Loading comments…