Office 365 CLI v2.4

Office 365 CLI v2.4

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

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

Rename SharePoint site collections

SharePoint site collections are one of the main building blocks of intranets on Office 365. For a long time, while you could change some of their properties, the URL you picked when creating the particular site was permanent. The only way to change it was by creating a new site collection and migrating all its contents. Luckily this has changed recently, when Microsoft introduced the support for renaming site collections.

In this release, David Calabro contributed a command to rename site collections using the Office 365 CLI.

To rename a site collection, execute:

spo site rename --siteUrl http://contoso.sharepoint.com/samplesite --newSiteUrl http://contoso.sharepoint.com/renamed

Renaming sites can take a moment and if you're building a script that should continue after the site has been renamed, add the --wait option:

spo site rename --siteUrl http://contoso.sharepoint.com/samplesite --newSiteUrl http://contoso.sharepoint.com/renamed --wait

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

Set any property on webs

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.

In this version of the Office 365 CLI, we've extended the spo web set command with support for setting the value of any property exposed on the Web class in the SharePoint Client-Side Object Model. To set any property, simply specify its name as defined on the Web class and the desired value:

spo web set --webUrl https://contoso.sharepoint.com/sites/team-a --AllowAutomaticASPXPageIndexing true

We'd love to hear if you find this useful and if you'd like us to implement something similar for other SharePoint objects.

Report Outlook 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 additional commands for reporting the usage of OneDrive in Outlook. For more information about which reports are available, see the documentation.

Disable SharePoint Features

As Office 365 evolves, some functionality becomes obsolete and is replaced by new capabilities. To prevent your users from using these deprecated features, you might need to disable them on site collection or site level.

To help you automate managing SharePoint Features, Joakim Högberg contributed to this release of the Office 365 CLI a command to disable SharePoint Features.

To disable a SharePoint Feature, execute:

spo feature disable --url https://contoso.sharepoint.com/sites/sales --featureId 915c240e-a6cc-49b8-8b2c-0bff8b553ed3 --scope Site

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

Remove Yammer messages

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 remove Yammer messages.

To remove the particular Yammer message:

yammer message remove --id 1239871123

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.

List Power Platform connectors

Building no-code and low-code solutions on the Power Platform gained a lot of popularity lately. Using Power Platform organizations can more quickly build compelling solutions and deploy them to their users. But Power Platform is not just for power users. IT departments can extend the capabilities of Power Platform by building custom connectors that allow power users to connect their solutions to organization's line of business systems.

In this version of the Office 365 CLI, we've introduced the support for listing custom Power Platform connectors which is useful in automating their management.

To list Power Platform connectors available in the given environment, execute:

pa connector list --environment Default-d87a7535-dd31-4437-bfe1-95340acd55c5

In the future versions of the Office 365 CLI we'll introduce further support for managing Power Platform connectors including exporting, validating and updating them.

Contributors

This release wouldn't be possible without the help of (in alphabetical order) David Calabro, Velin Georgiev, Joakim Högberg, 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? In this 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.

Comments

comments powered by Disqus