Office 365 CLI v1.11.0


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 the Office 365 CLI, you can manage your SharePoint Framework projects.

New version of Office 365 CLI - v1.11.0

As Microsoft has released a new version of the SharePoint Framework (v1.7.1), we’ve published a new version of the CLI to help you upgrade your projects to the latest version of SPFx. But there are a few more additions as well.

Upgrade SharePoint Framework projects to SharePoint Framework v1.7.1

Version 1.7.1 of the SharePoint Framework addresses some issues related to working with Yarn and building solutions using the dynamic data capability. To ensure that you haven’t missed anything while upgrading your projects, use the Office 365 CLI to get a full report of changes that need to be applied to your project.

To upgrade your existing SharePoint Framework project to v1.7.1 using the Office 365 CLI:

  • Update the Office 365 CLI to the latest version by executing: npm install -g @pnp/office365-cli@latest
  • Next, change the working directory to where your SharePoint Framework project is located and execute o365 spfx project upgrade --output md > report.md. This will produce a markdown file with the list of changes that need to be applied to your SharePoint Framework project.

Important: Office 365 CLI doesn’t change your project files and you need to apply the necessary changes yourself. For more information about upgrading SharePoint Framework projects using the Office 365 CLI, read Easily upgrade SharePoint Framework projects with the Office 365 CLI

Add webhooks

When building SharePoint applications, a common requirement is to be able to respond to activities in SharePoint, such as creating or editing a list item or document. In SharePoint Online, next to using Remote Event Receivers, you can use webhooks to get notified of changes in SharePoint content and configuration. For this release of the Office 365 CLI, Arjen Bloemsma continued his work on the support for webhooks, and contributed a command to add webhooks to lists.

To add a webhook, execute:

spo list webhook add --webUrl https://contoso.sharepoint.com/sites/ninja --listTitle Documents --notificationUrl https://contoso-functions.azurewebsites.net/webhook

For more information about managing webhooks using the Office 365 CLI, see the documentation at aka.ms/o365-cli.

Set modern page headers

More and more organizations are moving their portals and sites to the modern SharePoint experience which is more user-friendly and suitable for a wider range of use cases, including mobile devices. Using modern pages organizations can publish content and communicate information to their employees. To give them flexibility in how the information is presented, modern pages offer a number of headers that you can choose from.

To configure a header image for a modern page, execute:

spo page header set --webUrl https://contoso.sharepoint.com/sites/team-a --pageName home.aspx --type Custom --imageUrl /sites/team-a/SiteAssets/hero.jpg --altText 'Sunset over the ocean' --translateX 42.3837520042758 --translateY 56.4285714285714

For more information about working with modern pages using the Office 365 CLI, see the documentation at aka.ms/o365-cli.

Support for site collection app catalogs

A while ago already, Microsoft introduced support for site collection app catalogs as a way to help organizations manage their SharePoint solutions. By deploying their applications to site collection app catalogs, organizations can make the application available only on that specific site. Site collection app catalogs are disabled by default and can be enabled on specific sites by tenant admins.

For this release of the Office 365 CLI, Velin Georgiev and Andrew Connell contributed an update to a number of CLI commands that allow users to manage apps. Commands spo app add, spo app deploy, spo app get, spo app list and spo app remove now support working with apps deployed to site collection app catalogs. Velin and Andrew are going to continue their work on the support for site collection app catalogs and we should see a full support in all commands in the future versions of the CLI.

For more information about managing apps using the Office 365 CLI, see the documentation at aka.ms/o365-cli.

Improved adding preconfigured web parts to modern pages

Using the Office 365 CLI, you can add preconfigured web parts to modern pages. This is useful when you want to create a number of pages with web parts already on them or need to update a set of pages and don’t want to do it manually.

It turns out that some web parts, such as the Image web part, store some of their configuration data outside of web part properties. In this release of the Office 365 CLI, we’ve added a new option to the spo page clientsidewebpart add command which allows you to specify full web part configuration.

To add a preconfigured Image web part to a modern page, execute:

spo page clientsidewebpart add --webUrl https://contoso.sharepoint.com/sites/a-team --pageName page.aspx --standardWebPart Image --webPartData '`{ "dataVersion": "1.8", "serverProcessedContent": {"htmlStrings":{},"searchablePlainTexts":{"captionText":""},"imageSources":{"imageSource":"/sites/team-a/SiteAssets/work-life-balance.png"},"links":{}}, "properties": {"imageSourceType":2,"altText":"a group of people on a beach","overlayText":"Work life balance","fileName":"48146-OFF12_Justice_01.png","siteId":"27664b85-067d-4be9-a7d7-89b2e804d09f","webId":"a7664b85-067d-4be9-a7d7-89b2e804d09f","listId":"37664b85-067d-4be9-a7d7-89b2e804d09f","uniqueId":"67664b85-067d-4be9-a7d7-89b2e804d09f","imgWidth":650,"imgHeight":433,"fixAspectRatio":false,"isOverlayTextEnabled":true}}`'

For more information about working with modern pages using the Office 365 CLI, see the documentation at aka.ms/o365-cli.

Bug fixes and minor changes

For a complete list of changes including bug fixes and minor changes, see the release notes.

Contributors

This release wouldn’t be possible without the help of (in alphabetical order) Albert-Jan Schot, Andrew Connell, Arjen Bloemsma and Velin Georgiev. 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.

Setup script for the PnP SharePoint Starter Kit

A while back already, the SharePoint PnP team released the SharePoint Starter Kit: an end-to-end solution illustrating how to use the latest capabilities to build a modern intranet on Office 365. This starter kit will keep evolving as new capabilities are added to Office 365.

To help you setup the solution in your tenant, the PnP team released a setup script based on PnP PowerShell. Due to the current limitations of PnP PowerShell this script can be used only on Windows.

What if we had an equivalent script built in bash, using the Office 365 CLI which you could use on any platform?

I’ve already started working on this script in a separate repo. The basic structure is almost in place and ready for external contributions. Would you be interested in helping out with it?

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.

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: