CLI for Microsoft 365 v6.3
We’ve just published a new minor version of the CLI for Microsoft 365 with new commands for working with and managing Microsoft 365 and SharePoint Framework projects on any platform.
CLI for Microsoft 365 is a cross-platform CLI that allows you to manage various configuration settings of Microsoft 365 and SharePoint Framework projects no matter which operating system or shell you use.
While building solutions for Microsoft 365 expands beyond the Windows operating system, managing many platform settings is possible only through PowerShell on Windows. As more and more users work on non-Windows machines, it’s inconvenient for them to use a Windows virtual machine to configure their tenants. With the CLI for Microsoft 365, you can configure your tenant no matter which operating system you use. Additionally, using CLI for Microsoft 365, you can manage your SharePoint Framework projects.
Following our monthly release cadence, we’ve released a new version of the CLI for Microsoft 365 with some new capabilities. February was no exception. We had a ton of improvements and no fewer than 33 new commands. Here are a few of the most noteworthy additions.
For the complete list of what’s new and changed, see the release notes.
Working with Azure AD is one of the things for which the CLI for Microsoft 365 is often used. In this release we’ve introduced a series of new commands for managing users.
To create a new user, run:
m365 aad user add --displayName "John Doe" --userName "email@example.com" --password "SomePassw0rd" --forceChangePasswordNextSignIn
To delete a user, run:
m365 aad user remove --name firstname.lastname@example.org
To list license details of a specific user, run:
m365 aad user license list --userName email@example.com
Here’s a list of all new Azure AD commands for this release:
- aad license list
- aad user add
- aad user remove
- aad user license list
- aad user license add
- aad user license remove
- aad user recyclebinitem clear
- aad user recyclebinitem list
- aad user recyclebinitem remove
- aad user recyclebinitem restore
In this release, another series of Microsoft Planner commands are introduced. With these commands you can manage Planner Roster. Rosters are a new type of container that you can use to manage access to planner plans without the need for a Microsoft 365 group.
To create a new Microsoft Planner Roster, run:
m365 planner roster add
To give a user access to a Microsoft Planner Roster, run:
m365 planner roster member add --rosterId tYqYlNd6eECmsNhN_fcq85cAGAnd --userName firstname.lastname@example.org
To list all users having access to a Microsoft Planner Roster, run:
m365 planner roster member list --rosterId tYqYlNd6eECmsNhN_fcq85cAGAnd
Here’s a list of all new Planner commands for this release:
- planner roster add
- planner roster get
- planner roster remove
- planner roster member add
- planner roster member list
- planner roster member remove
The last few releases we introduced a lot of new commands around managing and applying Microsoft 365 Purview retention labels. This release we’re expanding on that. We’ve introduced new commands for managing event-based retention labels and for accessing the audit log within your tenant.
To list all SharePoint audit logs for the past 24 hours, run:
m365 purview auditlog list --contentType SharePoint
To create a retention event type, run:
m365 purview retentioneventtype add --displayName 'Contract Expiry' --description 'A retention event type to start a retention period based on the date that a contract expired.'
To list all retention event types, run:
m365 purview retentioneventtype list
To list all retention events, run:
m365 purview retentionevent list
Here’s a list of all new Compliance commands for this release:
- purview auditlog list
- purview retentionevent get
- purview retentionevent list
- purview retentionevent remove
- purview retentioneventtype add
- purview retentioneventtype get
- purview retentioneventtype list
- purview retentioneventtype remove
- purview retentioneventtype set
The CLI for Microsoft 365 has a lot of commands for managing and accessing SharePoint. In this release, more commands were introduced that make managing SharePoint easier. The main subjects are Application Customizers, Sharing Links and Navigation:
To add an application customizer to a SharePoint site, run:
m365 spo applicationcustomizer add --title 'Some customizer' --clientSideComponentId 799883f5-7962-4384-a10a-105adaec6ffc --webUrl https://contoso.sharepoint.com/sites/sales
To remove all sharing links from a file, run:
m365 spo file sharinglink clear --webUrl https://contoso.sharepoint.com/sites/demo --fileUrl '/sites/demo/Shared Documents/document.docx'
To update the title and intended audience of a navigation node, run:
m365 spo navigation node set --webUrl https://contoso.sharepoint.com/sites/marketing --id 2209 --title "Pictures" --audienceIds "61f78c73-f71a-471e-a3b9-15daa936e200,9524e6b4-e663-44fe-b179-210c963e37e7,c42b8756-494d-4141-a575-45f01320e26a"
Here’s a list of all new SharePoint commands for this release:
- spo tenant applicationcustomizer add
- spo applicationcustomizer add
- spo file sharinglink clear
- spo file sharinglink set
- spo navigation node get
- spo navigation node set
Granting permissions in SharePoint Framework projects can be a bother. Developers need to deploy the package before the permissions are visible on the API access page of the SharePoint admin dashboard. This process takes a lot of small steps. In this release we introduce a new command to make this process easier. You can now grant consent to all API permissions that are included in your SPFx project. No need to execute multiple gulp commands. No need to leave VS Code.
You can now simply run:
m365 spfx project permissions grant
In our previous releases, we have taken the first steps to creating a CLI context. This allows you to save time by storing default values for options that you often use. For example, if you’re working with a specific site collection, you can save the URL of the site collection in the context, and CLI for Microsoft 365 will automatically use it when you run a command that requires the URL of the site collection. This way, you don’t have to specify the URL of the site collection every time you run a command. In this release, we created an extra command to work with the CLI context. Note this is still a work in progress. We allow managing context settings but don’t apply them to commands just yet.
To list all options added to the context, run:
m365 context option list
Aside from new commands, we implemented a ton of enhancements and bugfixes. One we want to call out here is the command to list flow runs. It’s now possible to list flow runs by status and within a time range.
To get a list of all currently running instances of a Power Automate flow, run:
m365 flow run list --environmentName Default-d87a7535-dd31-4437-bfe1-95340acd55c5 --flowName 5923cb07-ce1a-4a5c-ab81-257ce820109a --status Running
To list runs of the specified Microsoft Flow between a specific time range, run:
m365 flow run list --environmentName Default-d87a7535-dd31-4437-bfe1-95340acd55c5 --flowName 5923cb07-ce1a-4a5c-ab81-257ce820109a --triggerStartTime 2023-01-21T18:19:00Z --triggerEndTime 2023-01-22T00:00:00Z
Here are some things that we are currently working on.
We’re currently busy implementing a new commands for managing the owners of a Power Automate flow. Things like listing, adding and removing owners.
We’re currently busy implementing the last of a series of commands around retention labels. Aside from that, work is also being done to build new commands to manage threat assessments and sensitivity labels.
In the upcoming weeks, we’ll keep working to create more commands to add, set, list, and remove SPFx extensions such as ListView Command Sets or Application Customizers.
This release wouldn’t be possible without the help of (in alphabetical order):
- Adam Wójcik
- Jasey Waegebaert
- Martin Lingstuyl
- Mathijs Verbeeck
- Milan Holemans
- Nanddeep Nachan
- Nico De Cleyre
- Patrick Lamber
- Rabia Williams
- Reshmee Auckloo
- Waldek Mastykarz
Thank you all for the time you chose to spend on CLI for Microsoft 365 and for your help to advance it!
CLI for Microsoft 365 wouldn’t be where it is today if it weren’t for our users who provide us with feedback. High fives to the following people who took the time to share their feedback and ideas for improvement with us (in alphabetical order):
CLI for Microsoft 365 is constantly growing and evolving. We’re always looking for ways to improve. There are still many areas not covered by the CLI as well as many amazing ideas for unique features the tool might provide. Your feedback will help us make the right decisions in which areas we should focus on. If you want to help out please do join the currently open discussions
Get the latest release of CLI for Microsoft 365 from npm by executing:
npm i -g @pnp/cli-microsoft365
Alternatively, you can get the latest release from Docker by executing:
docker run --rm -it m365pnp/cli-microsoft365:latest
If you need more help getting started or want more details about the commands, architecture, or project, go to aka.ms/cli-m365. If you see any room for improvement, please, don’t hesitate to reach out to us either on GitHub, Discord, or Twitter.