CLI for Microsoft 365 v3.10

Published 05-30-2021 11:31 PM 1,596 Views

CLI for Microsoft 365CLI for Microsoft 365

Manage 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 of the 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 have 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.
 
New version of CLI for Microsoft 365 – v3.10
Following our monthly release cadence, we’ve released a new version of the CLI for Microsoft 365 with some new capabilities. Here are a few of the most noteworthy additions.

 

Changes

We’ve continued improving CLI building upon the changes we’ve introduced in the previous version.
 
Added support for printing errors as JSON in JSON output
When scripting using the CLI, it is common to use the JSON output from commands which makes it easier to work with command responses. In the example below that uses PowerShell we can convert the JSON response into a PowerShell object using the ConvertFrom-Json cmdlet.
 
$lists = m365 todo list list -o json | ConvertFrom-Json
 
However if an error was thrown, the CLI would return the error as a plain text string and this can be inconvenient as your script is expecting a JSON response.
 
To help with error handling when using this approach, we have added support for changing the default error output type to JSON. To set the default output type for errors, execute:
 
m365 cli config set --key printErrorsAsPlainText --value false
 
Enhanced spo site apppermission commands
When working with site app permissions using the CLI we previously did not return information about the app roles which can be defined, therefore we have added returning the app roles when using the spo site apppermission get and spo site apppermission list commands in the response.
 

New Commands

Gets Azure AD app registration roles

When creating applications that use Azure AD authentication we can define custom roles that we can assign permissions to users or apps. The application defines and publishes the app roles and interprets them as permissions during authorization. 

 

To return the roles published by an Azure AD application registration by its name, execute:

 

m365 aad app role list --appName "My app"

 

Get the value of a CLI for Microsoft 365 configuration option

We recently announced that we added support for configuring the CLI to your own preferences using the cli config set command, this enables you to change some of the default settings such as changing all command outputs to be JSON rather than text.

 

To return the current value of a CLI configuration option, execute:

 

m365 cli config get --key output

 

Upload files using Microsoft Graph

The ability to upload files has been possible in the CLI for some time using the spo file add command, this command however uses SharePoint-based APIs to perform the upload and does not support new authorisation features such as the ability to control app access to specific site collections using the Sites.Selected permission scope.

 

To add support for the new permission scope, we have added a new command that uses the Microsoft Graph in its implementation, the existing spo file add command will remain to provide backwards compatibility.

 

To add a file to a specific site, execute:

 

m365 file add --filePath file.pdf --folderUrl "https://contoso.sharepoint.com/Shared Documents"

 

Remove a specified Power App

Microsoft Power Apps is a popular no/low code business application development platform in Microsoft 365 and managing apps created by business users is an important maintenance tasks for administrators. We have extended our support for Power Apps by introducing a command to remove Power Apps from an environment.

 

To remove a specified Microsoft Power App, execute: 

 

m365 pa app remove --name 3989cb59-ce1a-4a5c-bb78-257c5c39381d

 

Updates a specific application permission for a site

The Microsoft Graph gives us the ability to create site permissions on SharePoint Online or OneDrive sites, which has been possible in the CLI using the spo site apppermission add command, however it was not possible to update these registrations so we have added a new command to add that support.

 

To update a specific application permission by its name on a given site collection, execute:

 

m365 spo site apppermission set --siteUrl https://contoso.sharepoint.com/sites/project-x --appDisplayName Foo --permission read

 

New script samples

 

CLI for Microsoft 365 is a great tool both for quick adjustments to the configuration of your Microsoft 365 tenant as well as automating more complex tasks. Because CLI for Microsoft 365 is cross-platform you can use it on any OS and in any shell. To help you get started using the CLI for Microsoft 365 for automation scenarios, we started gathering some sample scripts.

 

If you have any scripts that you use frequently, please share them with us so that we can learn more about the common automation scenarios.
 
Replace user in Microsoft 365 Group or Microsoft Team with another user
When an employee leaves an organisation you may want to find and replace the employee account with another account.
 
This script helps update the membership by accepting the old user to be replaced, the new user that will be added and a CSV file containing the groups or teams to be iterated over.
 
Monitor site collection storage usage
As a SharePoint Administrator one of your tasks is to ensure that the storage being used in your Microsoft 365 tenant does not exceed the allowance of your tenant so this does not negatively impact daily usage.
 
This script helps by iterating over all SharePoint Online sites in your Microsoft 365 tenant, listing any sites that are over a defined storage threshold and emails the results to a specific email address.
 
Add multiple folders in libraries using a CSV file
When adding files into SharePoint Online, a common task is to create a defined folder structure in target document libraries within a target SharePoint Online site before adding the files.
 
This script helps by showing how to create folder structures in different document libraries using a CSV file as an input.
 
Replace SharePoint Online Site Collection Administrator with another user
When an employee leaves an organisation you may want to find and replace the employee account with another account.
 
The script helps by removing a user from a given SharePoint Online site collection and adds a new user as a Site Collection Administrator.
 
Search Power Automate Flows for specific connections
Microsoft Power Automate is a very powerful workflow tool in Microsoft 365 which use connectors to integrate with different platforms, a common connector that is used is the SharePoint Online connector which help simplify requests made to SharePoint Online, however it can be difficult to get a view of which Power Automate Flows are connected to specific SharePoint Online sites.
 
This script helps by iterating over all Power Automate Flows in your Microsoft 365 tenant, searches the exported Flows for a given Site Collection URL and returns the results.
 

Contributors

 

This release wouldn’t be possible without the help of (in alphabetical order)

 

 

Thank you all for the time you chose to spend on the CLI for Microsoft 365 and your help to advance it!
 

Work in progress

 

Here are some things that we’re currently working on.

 

More commands, what else

 

Microsoft 365 is evolving and new capabilities are being released every day. With CLI for Microsoft 365, we aim to help you manage your tenant on any platform in a consistent way, no matter which part of Microsoft 365 you interact with. While we keep adding new commands to CLI for Microsoft 365 each release, we still barely scratched the surface with what’s possible in Microsoft 365. In the upcoming versions of the CLI for Microsoft, you can expect us to add more commands across the different workloads in Microsoft 365.
 

Updating Azure AD apps

 

Recently, we introduced a command to easily create Azure AD app registrations. Because they're backbone of every app you'd build on Microsoft 365, we think you should be able to create them as easily as possible. So with CLI for Microsoft 365, you can create a fully configured Azure AD app for the most common scenarios with just one line of code.
 
We're currently working on adding support for updating Azure AD app registration which will be helpful for example when building apps for Microsoft Teams. Stay tuned!
 

Script examples

 

In every release of the CLI for Microsoft 365, we introduce new commands for managing Microsoft 365. With over 350 commands across the different Microsoft 365 services, the CLI for Microsoft 365 has become a powerful tool, not just for managing your tenant but also for automating your daily work.

 

We’d love to show you how you can use the CLI for Microsoft 365 to build automation scripts in PowerShell Core and Bash. If you have any scripts using SPO or PnP PowerShell that you use frequently, please share them with us so that we can learn more about the common automation scenarios.
 

'ensure' commands

 

Recently, we shipped our first ensure command - an easy way to help you that a site with specific settings exists. If it doesn't, CLI creates it for you, if it does, CLI ensures it has the right properties. All in one line of code. We'd love to hear from you how you like it and if it's something you'd like us to implement for other commands as well.

 

Try it today

 

Get the latest release of the 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, the architecture or the 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 or twitter.
%3CLINGO-SUB%20id%3D%22lingo-sub-2400105%22%20slang%3D%22en-US%22%3ECLI%20for%20Microsoft%20365%20v3.10%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2400105%22%20slang%3D%22en-US%22%3E%3CH2%20id%3D%22toc-hId--443074284%22%20id%3D%22toc-hId--443074284%22%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22banner-cli-m365.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F285044iF5BB440A28D2027F%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22banner-cli-m365.png%22%20alt%3D%22CLI%20for%20Microsoft%20365%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3ECLI%20for%20Microsoft%20365%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId--496485426%22%20id%3D%22toc-hId-2044438549%22%20id%3D%22toc-hId-2044438549%22%3E%3CSPAN%3EManage%20Microsoft%20365%20and%20SharePoint%20Framework%20projects%20on%20any%20platform%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CDIV%3E%3CSPAN%3ECLI%20for%20Microsoft%20365%20is%20a%20cross-platform%20CLI%20that%20allows%20you%20to%20manage%20various%20configuration%20settings%20of%20Microsoft%20365%20and%20SharePoint%20Framework%20projects%20no%20matter%20which%20operating%20system%20or%20shell%20you%20use.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3EWhile%20building%20solutions%20for%20Microsoft%20365%20expands%20beyond%20the%20Windows%20operating%20system%2C%20managing%20many%20of%20the%20platform%20settings%20is%20possible%20only%20through%20PowerShell%20on%20Windows.%20As%20more%20and%20more%20users%20work%20on%20non-Windows%20machines%2C%20it%E2%80%99s%20inconvenient%20for%20them%20to%20have%20to%20use%20a%20Windows%20virtual%20machine%20to%20configure%20their%20tenants.%20With%20the%20CLI%20for%20Microsoft%20365%2C%20you%20can%20configure%20your%20tenant%20no%20matter%20which%20operating%20system%20you%20use.%20Additionally%2C%20using%20CLI%20for%20Microsoft%20365%2C%20you%20can%20manage%20your%20SharePoint%20Framework%20projects.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%20style%3D%22color%3A%20inherit%3B%20font-size%3A%2024px%3B%22%3ENew%20version%20of%20CLI%20for%20Microsoft%20365%20%E2%80%93%20v3.10%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSPAN%3EFollowing%20our%20monthly%20release%20cadence%2C%20we%E2%80%99ve%20released%20a%20new%20version%20of%20the%20CLI%20for%20Microsoft%20365%20with%20some%20new%20capabilities.%20Here%20are%20a%20few%20of%20the%20most%20noteworthy%20additions.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-183572944%22%20id%3D%22toc-hId-236984086%22%20id%3D%22toc-hId-236984086%22%3E%3CSPAN%3EChanges%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CDIV%3E%3CSPAN%3EWe%E2%80%99ve%20continued%20improving%20CLI%20building%20upon%20the%20changes%20we%E2%80%99ve%20introduced%20in%20the%20previous%20version.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSTRONG%3EAdded%20support%20for%20printing%20errors%20as%20JSON%20in%20JSON%20output%3C%2FSTRONG%3E%3C%2FDIV%3E%0A%3CDIV%3EWhen%20scripting%20using%20the%20CLI%2C%20it%20is%20common%20to%20use%20the%20JSON%20output%20from%20commands%20which%20makes%20it%20easier%20to%20work%20with%20command%20responses.%20In%20the%20example%20below%20that%20uses%20PowerShell%20we%20can%20convert%20the%20JSON%20response%20into%20a%20PowerShell%20object%20using%20the%20%3CEM%3EConvertFrom-Json%3C%2FEM%3E%20cmdlet.%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3E%24lists%20%3D%20m365%20todo%20list%20list%20-o%20json%20%7C%20ConvertFrom-Json%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3EHowever%20if%20an%20error%20was%20thrown%2C%20the%20CLI%20would%20return%20the%20error%20as%20a%20plain%20text%20string%20and%20this%20can%20be%20inconvenient%20as%20your%20script%20is%20expecting%20a%20JSON%20response.%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3ETo%20help%20with%20error%20handling%20when%20using%20this%20approach%2C%20we%20have%20added%20support%20for%20changing%20the%20default%20error%20output%20type%20to%20JSON.%20To%20set%20the%20default%20output%20type%20for%20errors%2C%20execute%3A%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Em365%20cli%20config%20set%20--key%20printErrorsAsPlainText%20--value%20false%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSTRONG%3EEnhanced%26nbsp%3Bspo%20site%20apppermission%20commands%3C%2FSTRONG%3E%3C%2FDIV%3E%0A%3CDIV%3EWhen%20working%20with%20site%20app%20permissions%20using%20the%20CLI%20we%20previously%20did%20not%20return%20information%20about%20the%20app%20roles%20which%20can%20be%20defined%2C%20therefore%20we%20have%20added%20returning%20the%20app%20roles%20when%20using%20the%20%3CEM%3Espo%20site%20apppermission%20get%3C%2FEM%3E%20and%20%3CEM%3Espo%20site%20apppermission%20list%3C%2FEM%3E%20commands%20in%20the%20response.%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%0A%3CH2%20id%3D%22toc-hId-1543689684%22%20id%3D%22toc-hId--1570470377%22%20id%3D%22toc-hId--1570470377%22%3E%3CSPAN%3ENew%20Commands%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3E%3CSTRONG%3EGets%20Azure%20AD%20app%20registration%20roles%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EWhen%20creating%20applications%20that%20use%20Azure%20AD%20authentication%20we%20can%20define%20custom%20%3CSPAN%3Eroles%20that%20we%20can%20assign%20permissions%20to%20users%20or%20apps.%20The%20application%20defines%20and%20publishes%20the%20app%20roles%20and%20interprets%20them%20as%20permissions%20during%20authorization.%3C%2FSPAN%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ETo%20return%20the%20roles%20published%20by%20an%20Azure%20AD%20application%20registration%20by%20its%20name%3C%2FSPAN%3E%2C%20execute%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Em365%20aad%20app%20role%20list%20--appName%20%22My%20app%22%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EGet%20the%20value%20of%20a%20CLI%20for%20Microsoft%20365%20configuration%20option%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EWe%20recently%20announced%20that%20we%20added%20support%20for%20configuring%20the%20CLI%20to%20your%20own%20preferences%20using%20the%20%3CEM%3Ecli%20config%20set%3C%2FEM%3E%20command%2C%20this%20enables%20you%20to%20change%20some%20of%20the%20default%20settings%20such%20as%20changing%20all%20command%20outputs%20to%20be%20JSON%20rather%20than%20text.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20return%20the%20current%20value%20of%20a%20CLI%20configuration%20option%2C%20execute%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Em365%20cli%20config%20get%20--key%20output%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CSPAN%3EUpload%20files%20using%20Microsoft%20Graph%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThe%20ability%20to%20upload%20files%20has%20been%20possible%20in%20the%20CLI%20for%20some%20time%20using%20the%26nbsp%3B%3CEM%3Espo%20file%20add%26nbsp%3B%3C%2FEM%3Ecommand%2C%20this%20command%20however%20uses%20SharePoint-based%20APIs%20to%20perform%20the%20upload%20and%20does%20not%20support%20new%20authorisation%20features%20such%20as%20the%20ability%20to%20control%20app%20access%20to%20specific%20site%20collections%20using%20the%20%3CEM%3ESites.Selected%3C%2FEM%3E%20permission%20scope.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20add%20support%20for%20the%20new%20permission%20scope%2C%20we%20have%20added%20a%20new%20command%20that%20uses%20the%20Microsoft%20Graph%20in%20its%20implementation%2C%20the%20existing%26nbsp%3B%3CEM%3Espo%20file%20add%3C%2FEM%3E%20command%20will%20remain%20to%20provide%20backwards%20compatibility.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20add%20a%20file%20to%20a%20specific%20site%2C%20execute%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Em365%20file%20add%20--filePath%20file.pdf%20--folderUrl%20%22https%3A%2F%2Fcontoso.sharepoint.com%2FShared%20Documents%22%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CSPAN%3ERemove%20a%20specified%20Power%20App%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EMicrosoft%20Power%20Apps%20is%20a%20popular%20no%2Flow%20code%20business%20application%20development%20platform%20in%20Microsoft%20365%20and%20managing%20apps%20created%20by%20business%20users%20is%20an%20important%20maintenance%20tasks%20for%20administrators.%20We%20have%20extended%20our%20support%20for%20Power%20Apps%20by%20introducing%20a%20command%20to%20remove%20Power%20Apps%20from%20an%20environment.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20remove%20a%20specified%20Microsoft%20Power%20App%2C%20execute%3A%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Em365%20pa%20app%20remove%20--name%203989cb59-ce1a-4a5c-bb78-257c5c39381d%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CSPAN%3EUpdates%20a%20specific%20application%20permission%20for%20a%20site%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThe%20Microsoft%20Graph%20gives%20us%20the%20ability%20to%20create%20site%20permissions%20on%20SharePoint%20Online%20or%20OneDrive%20sites%2C%20which%20has%20been%20possible%20in%20the%20CLI%20using%20the%20%3CEM%3Espo%20site%20apppermission%20add%3C%2FEM%3E%20command%2C%20however%20it%20was%20not%20possible%20to%20update%20these%20registrations%20so%20we%20have%20added%20a%20new%20command%20to%20add%20that%20support.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20update%20a%26nbsp%3Bspecific%20application%20permission%20by%20its%20name%20on%20a%20given%20site%20collection%2C%20execute%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Em365%20spo%20site%20apppermission%20set%20--siteUrl%20https%3A%2F%2Fcontoso.sharepoint.com%2Fsites%2Fproject-x%20--appDisplayName%20Foo%20--permission%20read%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CH2%20id%3D%22toc-hId-917042456%22%20id%3D%22toc-hId-917042456%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId--2071219242%22%20id%3D%22toc-hId--890412007%22%20id%3D%22toc-hId--890412007%22%3E%3CSPAN%3ENew%20script%20samples%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CSPAN%3ECLI%20for%20Microsoft%20365%20is%20a%20great%20tool%20both%20for%20quick%20adjustments%20to%20the%20configuration%20of%20your%20Microsoft%20365%20tenant%20as%20well%20as%20automating%20more%20complex%20tasks.%20Because%20CLI%20for%20Microsoft%20365%20is%20cross-platform%20you%20can%20use%20it%20on%20any%20OS%20and%20in%20any%20shell.%20To%20help%20you%20get%20started%20using%20the%20CLI%20for%20Microsoft%20365%20for%20automation%20scenarios%2C%20we%20started%20gathering%20some%20%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fpnp.github.io%2Fcli-microsoft365%2Fsample-scripts%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%3CSPAN%3Esample%20scripts%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%3E.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CSPAN%3EIf%20you%20have%20any%20scripts%20that%20you%20use%20frequently%2C%20please%20%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fpnp%2Fcli-microsoft365%2Fdiscussions%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSPAN%3Eshare%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%3E%26nbsp%3Bthem%20with%20us%20so%20that%20we%20can%20learn%20more%20about%20the%20common%20automation%20scenarios.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSTRONG%3EReplace%20user%20in%20Microsoft%20365%20Group%20or%20Microsoft%20Team%20with%20another%20user%3C%2FSTRONG%3E%3C%2FDIV%3E%0A%3CDIV%3EWhen%20an%20employee%20leaves%20an%20organisation%20you%20may%20want%20to%20find%20and%20replace%20the%20employee%20account%20with%20another%20account.%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3EThis%20script%26nbsp%3Bhelps%20%3CA%20href%3D%22https%3A%2F%2Fpnp.github.io%2Fcli-microsoft365%2Fsample-scripts%2Faad%2Freplace-membership-of-selected-groups%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Eupdate%20the%20membership%3C%2FA%3E%20by%20accepting%20the%20old%20user%20to%20be%20replaced%2C%20the%20new%20user%20that%20will%20be%20added%20and%20a%20CSV%20file%26nbsp%3Bcontaining%20the%20groups%20or%20teams%20to%20be%20iterated%20over.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSTRONG%3EMonitor%20site%20collection%20storage%20usage%3C%2FSTRONG%3E%3C%2FDIV%3E%0A%3CDIV%3EAs%20a%20SharePoint%20Administrator%20one%20of%20your%20tasks%20is%20to%20ensure%20that%20the%20storage%20being%20used%20in%20your%20Microsoft%20365%20tenant%20does%20not%20exceed%20the%20allowance%20of%20your%20tenant%20so%20this%20does%20not%20negatively%20impact%20daily%20usage.%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3EThis%20%3CA%20href%3D%22https%3A%2F%2Fpnp.github.io%2Fcli-microsoft365%2Fsample-scripts%2Fspo%2Fmonitor-site-collection-storage-usage%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Escript%3C%2FA%3E%20helps%20by%20iterating%20over%20all%20SharePoint%20Online%20sites%20in%20your%20Microsoft%20365%20tenant%2C%20listing%20any%20sites%20that%20are%20over%20a%20defined%20storage%20threshold%20and%20emails%20the%20results%20to%20a%20specific%20email%20address.%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSTRONG%3E%3CSPAN%3EAdd%20multiple%20folders%20in%20libraries%20using%20a%20CSV%20file%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FDIV%3E%0A%3CDIV%3EWhen%20adding%20files%20into%20SharePoint%20Online%2C%20a%20common%20task%20is%20to%20create%20a%20defined%20folder%20structure%20in%20target%20document%20libraries%20within%20a%20target%20SharePoint%20Online%20site%20before%20adding%20the%20files.%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3EThis%20%3CA%20href%3D%22https%3A%2F%2Fpnp.github.io%2Fcli-microsoft365%2Fsample-scripts%2Fspo%2Fadd-multiple-folders-in-libraries-using-csv-file%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Escript%3C%2FA%3E%20helps%20by%20showing%20how%20to%20create%20folder%20structures%20in%20different%20document%20libraries%20using%20a%20CSV%20file%20as%20an%20input.%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSTRONG%3E%3CSPAN%3EReplace%20SharePoint%20Online%20Site%20Collection%20Administrator%20with%20another%20user%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FDIV%3E%0A%3CDIV%3EWhen%20an%20employee%20leaves%20an%20organisation%20you%20may%20want%20to%20find%20and%20replace%20the%20employee%20account%20with%20another%20account.%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3EThe%20%3CA%20href%3D%22https%3A%2F%2Fpnp.github.io%2Fcli-microsoft365%2Fsample-scripts%2Fspo%2Freplace-site-collection-admin%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Escript%3C%2FA%3E%20helps%20by%20removing%20a%20user%20from%20a%20given%20SharePoint%20Online%20site%20collection%20and%20adds%20a%20new%20user%20as%20a%20Site%20Collection%20Administrator.%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSTRONG%3E%3CSPAN%3ESearch%20Power%20Automate%20Flows%20for%20specific%20connections%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FDIV%3E%0A%3CDIV%3EMicrosoft%20Power%20Automate%20is%20a%20very%20powerful%20workflow%20tool%20in%20Microsoft%20365%20which%20use%20connectors%20to%20integrate%20with%20different%20platforms%2C%20a%20common%20connector%20that%20is%20used%20is%20the%20SharePoint%20Online%20connector%20which%20help%20simplify%20requests%20made%20to%20SharePoint%20Online%2C%20however%20it%20can%20be%20difficult%20to%20get%20a%20view%20of%20which%20Power%20Automate%20Flows%20are%20connected%20to%20specific%20SharePoint%20Online%20sites.%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3EThis%20%3CA%20href%3D%22https%3A%2F%2Fpnp.github.io%2Fcli-microsoft365%2Fsample-scripts%2Fflow%2Fsearch-flows-for-connection%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Escript%3C%2FA%3E%20helps%20by%20iterating%20over%20all%20Power%20Automate%20Flows%20in%20your%20Microsoft%20365%20tenant%2C%20searches%20the%20exported%20Flows%20for%20a%20given%20Site%20Collection%20URL%20and%20returns%20the%20results.%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%0A%3CH2%20id%3D%22toc-hId-962667237%22%20id%3D%22toc-hId-1597100826%22%20id%3D%22toc-hId-1597100826%22%3E%3CSPAN%3EContributors%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CSPAN%3EThis%20release%20wouldn%E2%80%99t%20be%20possible%20without%20the%20help%20of%20(in%20alphabetical%20order)%20%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fcasvaniersel%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3ECas%20van%20Iersel%3C%2FA%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fvipulkelkar%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSPAN%3EVipul%20Kelkar%3C%2FSPAN%3E%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fplamber%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSPAN%3EPatrick%20Lamber%3C%2FSPAN%3E%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fveronicageek%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSPAN%3EVeronique%20Lengelle%3C%2FSPAN%3E%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fwaldekmastykarz%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EWaldek%20Mastykarz%3C%2FA%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAbderahman88%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSPAN%3EAbderahman%20Moujahid%3C%2FSPAN%3E%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fnanddeepn%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSPAN%3ENanddeep%20Nachan%3C%2FSPAN%3E%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fappieschot%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EAlbert%20Jan-Schot%3C%2FA%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fgarrytrinder%2F%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EGarry%20Trinder%3C%2FA%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CSPAN%3EThank%20you%20all%20for%20the%20time%20you%20chose%20to%20spend%20on%20the%20CLI%20for%20Microsoft%20365%20and%20your%20help%20to%20advance%20it!%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%0A%3CH2%20id%3D%22toc-hId--844787226%22%20id%3D%22toc-hId--210353637%22%20id%3D%22toc-hId--210353637%22%3E%3CSPAN%3EWork%20in%20progress%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CSPAN%3EHere%20are%20some%20things%20that%20we%E2%80%99re%20currently%20working%20on.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1771808326%22%20id%3D%22toc-hId-480207837%22%20id%3D%22toc-hId-480207837%22%3E%3CSPAN%3EMore%20commands%2C%20what%20else%3C%2FSPAN%3E%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CSPAN%3EMicrosoft%20365%20is%20evolving%20and%20new%20capabilities%20are%20being%20released%20every%20day.%20With%20CLI%20for%20Microsoft%20365%2C%20we%20aim%20to%20help%20you%20manage%20your%20tenant%20on%20any%20platform%20in%20a%20consistent%20way%2C%20no%20matter%20which%20part%20of%20Microsoft%20365%20you%20interact%20with.%20While%20we%20keep%20adding%20new%20commands%20to%20CLI%20for%20Microsoft%20365%20each%20release%2C%20we%20still%20barely%20scratched%20the%20surface%20with%20what%E2%80%99s%20possible%20in%20Microsoft%20365.%20In%20the%20upcoming%20versions%20of%20the%20CLI%20for%20Microsoft%2C%20you%20can%20expect%20us%20to%20add%20more%20commands%20across%20the%20different%20workloads%20in%20Microsoft%20365.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CH3%20id%3D%22toc-hId--1843100600%22%20id%3D%22toc-hId--1327246626%22%20id%3D%22toc-hId--1327246626%22%3E%3CSPAN%3EUpdating%20Azure%20AD%20apps%3C%2FSPAN%3E%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CSPAN%3ERecently%2C%20we%20introduced%20a%20command%20to%20easily%20create%20Azure%20AD%20app%20registrations.%20Because%20they're%20backbone%20of%20every%20app%20you'd%20build%20on%20Microsoft%20365%2C%20we%20think%20you%20should%20be%20able%20to%20create%20them%20as%20easily%20as%20possible.%20So%20with%20CLI%20for%20Microsoft%20365%2C%20you%20can%20create%20a%20fully%20configured%20Azure%20AD%20app%20for%20the%20most%20common%20scenarios%20with%20just%20one%20line%20of%20code.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CSPAN%3EWe're%20currently%20working%20on%20adding%20support%20for%20updating%20Azure%20AD%20app%20registration%20which%20will%20be%20helpful%20for%20example%20when%20building%20apps%20for%20Microsoft%20Teams.%20Stay%20tuned!%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CH3%20id%3D%22toc-hId-644412233%22%20id%3D%22toc-hId-465102728%22%20id%3D%22toc-hId-465102728%22%3E%3CSPAN%3EScript%20examples%3C%2FSPAN%3E%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CSPAN%3EIn%20every%20release%20of%20the%20CLI%20for%20Microsoft%20365%2C%20we%20introduce%20new%20commands%20for%20managing%20Microsoft%20365.%20With%20over%20350%20commands%20across%20the%20different%20Microsoft%20365%20services%2C%20the%20CLI%20for%20Microsoft%20365%20has%20become%20a%20powerful%20tool%2C%20not%20just%20for%20managing%20your%20tenant%20but%20also%20for%20automating%20your%20daily%20work.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CSPAN%3EWe%E2%80%99d%20love%20to%20show%20you%20how%20you%20can%20use%20the%20CLI%20for%20Microsoft%20365%20to%20build%20automation%20scripts%20in%20PowerShell%20Core%20and%20Bash.%20If%20you%20have%20any%20scripts%20using%20SPO%20or%20PnP%20PowerShell%20that%20you%20use%20frequently%2C%20please%20share%20them%20with%20us%20so%20that%20we%20can%20learn%20more%20about%20the%20common%20automation%20scenarios.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CH3%20id%3D%22toc-hId--1163042230%22%20id%3D%22toc-hId--1342351735%22%20id%3D%22toc-hId--1342351735%22%3E%3CSPAN%3E'ensure'%20commands%3C%2FSPAN%3E%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CSPAN%3ERecently%2C%20we%20shipped%20our%20first%20ensure%20command%20-%20an%20%3CA%20href%3D%22https%3A%2F%2Fpnp.github.io%2Fcli-microsoft365%2Fcmd%2Fspo%2Fsite%2Fsite-ensure%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Eeasy%20way%20to%20help%20you%20that%20a%20site%20with%20specific%20settings%20exists%3C%2FA%3E.%20If%20it%20doesn't%2C%20CLI%20creates%20it%20for%20you%2C%20if%20it%20does%2C%20CLI%20ensures%20it%20has%20the%20right%20properties.%20All%20in%20one%20line%20of%20code.%20We'd%20love%20to%20hear%20from%20you%20how%20you%20like%20it%20and%20if%20it's%20something%20you'd%20like%20us%20to%20implement%20for%20other%20commands%20as%20well.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1195387884%22%20id%3D%22toc-hId-1016078379%22%20id%3D%22toc-hId-1016078379%22%3E%3CSPAN%3ETry%20it%20today%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CSPAN%3EGet%20the%20latest%20release%20of%20the%20CLI%20for%20Microsoft%20365%20from%20npm%20by%20executing%3A%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Enpm%20i%20-g%20%40pnp%2Fcli-microsoft365%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CSPAN%3EAlternatively%2C%20you%20can%20get%20the%20latest%20release%20from%20Docker%20by%20executing%3A%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Edocker%20run%20--rm%20-it%20m365pnp%2Fcli-microsoft365%3Alatest%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CSPAN%3EIf%20you%20need%20more%20help%20getting%20started%20or%20want%20more%20details%20about%20the%20commands%2C%20the%20architecture%20or%20the%20project%2C%20go%20to%20%3C%2FSPAN%3E%3CA%20href%3D%22http%3A%2F%2Faka.ms%2Fcli-m365%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSPAN%3Eaka.ms%2Fcli-m365%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%3E.%20%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CSPAN%3EIf%20you%20see%20any%20room%20for%20improvement%2C%20please%2C%20don%E2%80%99t%20hesitate%20to%20reach%20out%20to%20us%20either%20on%20%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fpnp%2Fcli-microsoft365%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSPAN%3EGitHub%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%3E%26nbsp%3Bor%20%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Ftwitter.com%2Fclimicrosoft365%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%3CSPAN%3Etwitter%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%3E.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2400105%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3ECLI%20for%20Microsoft%20365%20is%20a%20cross-platform%20CLI%20that%20allows%20you%20to%20manage%20various%20configuration%20settings%20of%20Microsoft%20365%20and%20SharePoint%20Framework%20projects%20no%20matter%20which%20operating%20system%20or%20shell%20you%20use.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Co-Authors
Version history
Last update:
‎May 30 2021 11:31 PM
Updated by: