There are a lot of useful things you can do with the Microsoft 365 CLI, and choosing 5 things was hard. These are the things I use the most – but depending on your specific tasks there might be other commands that are more useful for you – so I recomend to also take a look at all the M365 CLI has to offer.
npm install -g @pnp/cli-microsoft365
1. Manage your app registrations
Almost every Microsoft 365 app you are building needs an Azure AD app registration, and with the M365 CLI you can easeli manage those registrations. Waldek Mastyrkarz have a great blogpost that covers this in more details.
// Register new app - see documentation (linked below) for more options m365 aad app add --name 'My app name' // Get app registration by appid m365 aad app get --appId <app GUID goes here>
Documentation for M365 CLI Azure AD app registrations
2. Get a report on how to upgrade your SPfx solution
I also mentioned this in my latest blogpost about upgrading SPfx solutions, but its so useful it should be mentioned again. This command will generate a report that tells you how to update your SPfx solution step by step.
m365 spfx project upgrade --toVersion 1.14.0 --output md > "upgrade-report.md"
Documentation for package upgrade
3. Add app to SPO app catalog
One of my first blogposts covers how to deploy your SPfx packages with PnP powershell. And you could still do it like described there, but recently I’ve been using the M356 CLI for this too.
m365 spo app add --filePath ../yourPathHere/spfx-app-package.sppkg
4. SPFx doctor
The SPfx doctor is very useful if you ever have to take over an app from someone else, or if you are on a new/different computer, then you can use the spfx doctor
command to see if your environment meets the prerequesites for the version of SPfx used.
m365 spfx doctor
5. Managing apps in Teams
If you are developing apps for Teams the M365 CLI offers some great tools to manage these apps.
Get list of all apps in a team
// From your organizations app catalog. Add parameter --all to see all apps (not only from org) m365 teams app list // See apps in specific team m365 teams app list --teamId <Your team GUID here>
Install or uninstall app
// Install m365 teams app install --appId <your app-id here> // Uninstall m365 teams app uninstall --appId <your app-id here>
You can also publish an app or remove an app with M365 CLI.
Did you find this article usefull? Follow me on twitter to be notified when I publish something new!
If you are interested in Microsoft 365 Development you might also like my other blogposts in this category.
Also, if you have any feedback or questions, please let me know in the comments below. š
Thank you for reading, and happy coding!
/Eli