Office 365 CLI v2.5 and v2.6


We’ve just published a new version of the Office 365 CLI with new commands for working with and managing Office 365 tenants and SharePoint Framework projects on any platform.

Manage Office 365 and SharePoint Framework projects on any platform

Office 365 CLI is a cross-platform CLI that allows you to manage various configuration settings of Office 365 and SharePoint Framework projects no matter which operating system or shell you use.

While building solutions for Office 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 Office 365 CLI, you can configure your tenant no matter which operating system you use. Additionally, using Office 365 CLI, you can manage your SharePoint Framework projects.

New version of Office 365 CLI - v2.5 and v2.6

Following the release of SharePoint Framework v1.10 we released v2.5 of the Office 365 CLI allowing developers to upgrade their projects to the latest version of the SharePoint Framework. Aside from it, we stuck to our monthly release cadence, we’ve released a new version of the Office 365 CLI with some new capabilities (v2.6).

Upgrade SharePoint Framework projects to v1.10

By now, SharePoint Framework is the standard way of extending modern SharePoint to your needs. But despite its name, it’s not only for SharePoint. Using the SharePoint Framework, you can build applications that can be exposed also in Microsoft Teams and recently even in Office add-ins!

The steps required to upgrade your SharePoint Framework project to a newer version vary from version to version. One thing that’s sure however, is that often you need to do more than just increase the version of SharePoint Framework dependencies.

Office 365 CLI simplifies the upgrade process. Knowing all the differences between the different versions of the SharePoint Framework, it scans your project and presents you with a report containing all the upgrade steps necessary to properly move your project to the specified version of the SharePoint Framework.

For example, to get instructions how to upgrade your SharePoint Framework project to the latest version of the SharePoint Framework, in the command line change the working directory to your SharePoint Framework project and execute:

spfx project upgrade --output md

For more information about upgrading SharePoint Framework projects using the Office 365 CLI, see the documentation.

Office 365 CLI GitHub actions

GitHub Actions makes it easy to automate all your software workflows, now with world-class CI/CD. Build, test, and deploy your code right from GitHub. Make code reviews, branch management, and issue triaging work the way you want.

If you use GitHub as your CI/CD system and build solutions for Microsoft 365, you can now use Office 365 CLI through GitHub actions to simplify communicating with your tenant in your DevOps process. See the documentation for the actions that are available and how to use them.

Big thanks to Anoop Tatti for the original idea and contributing the actions and Velin Georgiev and Garry Trinder for the quality checks and the docs.

Export custom Power Platform connectors

Power Platform empowers organizations on the Microsoft cloud to build powerful solutions to automate their business processes. Through the use of connectors, these flows and Power Apps can connect to the different services and interact with their data. Next to using standard connectors provided by Microsoft and ISVs, organizations can build custom connectors to connect the Power Platform to their systems.

When building custom Power Platform connectors, you might need to export them either to back them up, to move them between environments or to publish them for everyone else to use. To export a custom connector you can use the paconn tool provided by Microsoft. If you have trouble using it due to its dependencies (Python) or errors, you can try the export functionality available in the Office 365 CLI, which we have introduced in this release and which gives you the same result.

To export a custom Power Platform connector using the Office 365 CLI, execute:

pa connector export --environment Default-d87a7535-dd31-4437-bfe1-95340acd55c5 --connector shared_connector-201-5f20a1f2d8d6777a75-5fa602f410652f4dfa

To get the list of available environments, use the flow environment list command. To get the list of custom connectors, use the pa connector list command.

For more information about working with custom connectors using the Office 365 CLI, see the documentation at aka.ms/o365cli.

Improved performance of command completion

When using the Office 365 CLI in immersive mode (meaning, you type in the console o365 which starts a new command prompt and takes over your session), you get command completion for all commands and their options available in the Office 365 CLI. The immersive mode offers you a rich experience and convenience but because it takes over the session, you can’t use any other shell command available on your computer.

You can also use the Office 365 CLI in a non-immersive mode, where you type the whole command that you want to execute along with its options, eg. spo site list --type TeamSite. To help you use the CLI in non-immersive mode, we also provided command completion for the different shells. Unfortunately, the way the completion for non-immersive mode was built, is that each time you’d type o365 [TAB], it would launch the CLI to get the list of completions, which was slow and lead to a poor experience.

In this release of the Office 365 CLI, we’ve separated the completion from the CLI. Using a prebuilt list of commands and their options it executes very fast providing you with relevant completions with barely any delay. If you use bash, give it a try and shortly, you will be able to try it out in PowerShell as well!

Added support for filtering command output using JMESPath

Using the Office 365 CLI you can retrieve information about many objects in Microsoft 365. In the default text mode, the retrieved information is trimmed for readability but when you switch to JSON output, you will get access to all properties exposed by the particular API.

Not all shells have native support for working with JSON. And to make it easier for you to get the right information, we’ve introduced support for filtering the command output using JMESPath queries, which you might know from the Azure CLI.

For example, to retrieve all sites in your tenant that use a specific template, you would execute:

o365 spo site list --output json --query "[?Template == 'GROUP#0'].{Title: Title, Url: Url}"

For more information about the output modes and using JMESPath with the Office 365 CLI, see the documentation.

Improved externalizing SharePoint Framework dependencies

When building SharePoint Framework solutions, developers can benefit of existing libraries and focus on things specific for their organizations. The downside of using these libraries is that they extend the size of your solution. To address this problem, you can reference libraries from external source rather than having them included in your solution bundle.

In a recent version of the Office 365 CLI, Vincent Biret contributed a command to help you externalize references to libraries in your SharePoint Framework solution. To get an overview of steps to exclude libraries from your project, change the working directory to your SharePoint Framework project and execute:

spfx project externalize --output md

In this version Vincent has further improved the process of detecting the library references and the upgrade report. We’d love you to try the command in your project and tell us what you think.

Report SharePoint and OneDrive usage

Many organizations that use Office 365 need to track and report on how their employees use the different services provided by Microsoft. The Office 365 Admin Center, as well as the admin centers dedicated to managing the different services, offer a number of reports that illustrate the usage from different perspectives.

In case you need to automate reporting in scripts, Patrick Lamber continued his great work introducing 11 additional commands for reporting the usage of OneDrive and SharePoint. For more information about which reports are available, see the documentation.

Remove Microsoft Graph schema extensions

Using the Microsoft Graph, developers can store additional information about objects like users or messages. Developers can define the shape of this additional pieces of information through schema extensions. For this release of the Office 365 CLI, Yannick Plenevaux contributed a command to remove schema extension from your environment.

To remove a schema extension from your environment, execute:

graph schemaextension remove --id domain_myExtension

For more information about working with schema extensions using the Office 365 CLI, see the documentation at aka.ms/o365cli.

List Yammer groups

Organizations on Office 365 have plenty of choices when it comes to how to facilitate their collaboration. They can choose the good old e-mail, but also can use services like Microsoft Teams or Yammer. Each of these services shines in one or more specific scenarios and there is no right or wrong when it comes to using them in the workplace.

In this release of the Office 365 CLI, we continued to extend support for Yammer. Patrick Lambert contributed a command to list Yammer groups.

To list Yammer groups, execute:

yammer group list

Since Yammer is not available in all tenants, we made its permissions optional in the Azure AD app used by the Office 365 CLI. Before you can start using Yammer commands in the Office 365 CLI, you need to consent the Azure AD app access to Yammer by executing:

consent --service yammer

For more information about managing Yammer using the Office 365 CLI, see the documentation.

Contributors

This release wouldn’t be possible without the help of (in alphabetical order) Vincent Biret, Velin Georgiev, Patrick Lamber, Anoop Tatti, Garry Trinder, Siddharth Vaghasia and Rabia Williams. Thank you all for the time you chose to spend on the Office 365 CLI and your help to advance it!

Work in progress

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

More commands, what else

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

To make it easier for you to see how the CLI commands compare to the different PowerShell cmdlets, we’ve extended the comparison sheet with cmdlets for Flow, PowerApps, and Teams.

Script examples

In every release of the Office 365 CLI, we introduce new commands for managing Office 365. With almost 350 commands across the different Office 365 services, the Office 365 CLI has become a powerful tool, not just for managing your tenant but also for automating your daily work. In the coming weeks, we want to spend some time to show you how you can use the Office 365 CLI 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.

Setting arbitrary properties on SharePoint objects

At this moment, the most of SharePoint set commands in the Office 365 CLI support only a handful of options that correspond to the properties of their SharePoint class, like Web, Site, List, etc. This is similar to the how the Set-PnP* cmdlets work. However, because PnP PowerShell works with CSOM, this limitation there is often circumvented, by retrieving the CSOM object, updating its properties and calling $object.ExecuteQuery() to persist the changes outside of PnP cmdlets. Because the CLI doesn’t use CSOM, this isn’t possible and users are limited to using whatever options are exposed by the CLI commands.

We’re thinking about addressing this limitation by allowing you to set the value of any property exposed on the SharePoint object. This would work only for properties that have values of simple types like bool, string or int, because complex values likely can’t be serialized to string without additional logic.

We would offer rudimentary logic of checking if the specified properties are valid, by examining the latest version of the SPO CSOM assemblies and checking which properties on the particular SharePoint class have setters and values of the supported types and thus can be used.

What do you think of this approach? Would this help to solve a problem you have? In the previous release we have extended the spo web set command with this functionality. We’d love you to try it and tell us what you think, either in the comments below or on twitter @office365cli.

Support for batch operations

If you need to create hundreds or thousands of list items, creating them one by one could take a long time. What if we could speed this up, by supporting batch operations? You would provide the list of items to create through an input file (for example CSV) and the CLI would create them for you as quickly as possible. Would this be helpful? What should we take into account? We’d love to hear from you.

Try it today

Get the latest release of the Office 365 CLI from npm by executing in the command line:

npm i -g @pnp/office365-cli

If you need more help getting started or want more details about the commands, the architecture or the project, go to aka.ms/o365cli. If you see any room for improvement, please, don’t hesitate to reach out to us either on GitHub, on twitter with the #office365cli hashtag or on gitter.

Others found also helpful: