Office 365 CLI v2.3


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.3

Following our monthly release cadence, we’ve released a new version of the Office 365 CLI with some new capabilities.

Externalize dependencies of SharePoint Framework projects

When building solutions on the SharePoint Framework, there are over 1 million packages on npm that you can use to speed up the development process and focus on the added value for your organization/customers. All these dependencies however, add to the size of your package and could eventually lead to poor performance of pages using your solution. One way to address this challenge is to load dependencies from external location, allowing users to cache them separately of your solution.

For this version of the Office 365 CLI, Vincent Biret in collaboration with Rencore contributed a command that provides you with recommendations how to externalize dependencies that you use in your project. To get the recommendations for your project, change the working directory to your SharePoint Framework project and execute:

o365 spfx project externalize --output md --outputFile report.md

The command is still in preview and we’d love to hear from you what you think of it. For more information about how the command works see the documentation.

Manage Yammer on any platform

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 three commands to retrieve information about Yammer messages and list users from the current Yammer network.

To list all messages from the current Yammer network execute:

yammer message list

To get information about a specific message execute:

yammer message get --id 1239871123

To list all users from the current Yammer network execute:

yammer user 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

Patrick has ideas for adding more Yammer commands to the Office 365 CLI which you can expect in the future releases.

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 and Garry Trinder. 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 275 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? We have a working example available for the spo web set command, which we will release in the next beta version of the CLI. We’d love to hear from you, 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: