Luise Freese

5 commands to try in CLI for Microsoft 365 to fall in love with it

5 commands to try in CLI for Microsoft 365 to fall in love with it


After I blogged about How to send Adaptive Cards with CLI for Microsoft 365 and also used CLI to compare different ways to create SharePoint lists, I found some more commands that made me fall in love with it. CLI for Microsoft 365 has three main benefits from my point of view:

  • 💻 it’s platform-agnostic and even works on Azure Cloud Shell so that every browser can be my admin machine
  • 💡 the syntax is easy and almost intuitive to use for me, although I only start to not use the UI for everything I want to manage in my Microsoft 365 tenant
  • 🚀 documentation is clear and concise with excellent code samples.

Bonus: 💖 Caring maintainers and awesome contributors

In case you never used CLI for Microsoft 365 before, please first read how to get started with CLI Microsoft 365 where I explain how to install the CLI.

My screenshots will show that I work in PowerShell in Visual Studio Code, but you can use any other shell you like to use.

Get a list of Power Apps

Wouldn’t it be nice to get a list of apps? This is what I thought as well. We will look into the CLI for Microsoft 365 documentation find the command to list all Power Apps in this tenant, which gives us an idea, what makers are doing to be able to offer help and support as well.

After having installed CLI and logged in:

Run m365 pa app list

which will get you exactly that list - with internal names and display names:

m365 pa app list

Get an overview of custom connectors in an environment

If we allowed makers to build their custom connectors to fulfill their unique needs, we might want to look at that as well. If you never create a custom connector, you can read my blog post about how to build a custom connector.

Run m365 pa environment get --name Default-<name of your default environment>

Now, where do we get this <name of your default environment> from? This is your tenant ID, which you can obtain from the URL of any Power App running in this environment, or you can copy it from, where you will find it in Azure Active Directory as Tenant ID.

obtain environment name in PA URL

  • Copy this Tenant ID
  • Replace <name of your default environment> with this Tenant ID
  • Run the command

Get a list of users

Obtaining a list of users on a specific SharePoint website will be helpful to get their IDs.

Run m365 spo user list --webUrl ""by replacing my webUrl with the tenant you are logged in and a site URL you want to query.

The response will be something like this:

list spo users

Get a list of external users

Another cool starting point is to get a list of external users. As internal users tend to invite many guests, it could help have an overview of external users and see when these external users were created. You can also obtain the ID of users.

m365 spo externaluser list,

get external users

remove users


m365 spo user remove --webUrl "" --id 10 --confirm

we can remove users.

Feedback & What’s next?

I hope that you now got an idea of how you can get started with CLI for Microsoft 365 :-) Shall I blog more about it and show even more commands? Still, I am curious, what would you use it for? Which are the commands that you use every single day? Please comment below!

You May Also Like