Office 365 CLI v1.5.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.5.0

As the vacation season is still in progress for some, here we are with a new version and new commands for the Office 365 CLI.

Manage columns

Columns in SharePoint are the foundation of storing the content’s metadata. All SharePoint solutions rely to some degree on custom columns, no matter if they’re provisioned to lists or sites. In this version of the Office 365 CLI, we’ve added support for creating new list- and site columns and retrieving information about existing columns.

To get information about an existing site column, execute:

spo field get --webUrl https://contoso.sharepoint.com/sites/contoso-sales --id 5ee2dd25-d941-455a-9bdb-7f2c54aed11b

To create a new site column, execute:

spo field add --webUrl https://contoso.sharepoint.com/sites/contoso-sales --xml '`<Field Type="DateTime" DisplayName="Start date-time" Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" Format="DateTime" Group="PnP Columns" FriendlyDisplayFormat="Disabled" ID="{5ee2dd25-d941-455a-9bdb-7f2c54aed11b}" SourceID="{4f118c69-66e0-497c-96ff-d7855ce0713d}" StaticName="PnPAlertStartDateTime" Name="PnPAlertStartDateTime"><Default>[today]</Default></Field>`'

For more information about working with list- and site columns using the Office 365 CLI, see the documentation at aka.ms/o365-cli.

Manage content types

Assigning content types to your content allows you to more easily manage it. You can define which metadata should be stored along the content, which of them are required, but you can also more easily find similar types of content stored across your whole intranet. If your solution works with content in SharePoint, chances are that it also requires some specific content types. In this version of the Office 365 CLI, we’ve added support for retrieving information about existing content types as well as creating new ones.

To get information about an existing site content type, execute:

spo contenttype get --webUrl https://contoso.sharepoint.com/sites/contoso-sales --id 0x0100558D85B7216F6A489A499DB361E1AE2F

To create a new site content type, execute:

spo contenttype add --webUrl https://contoso.sharepoint.com/sites/contoso-sales --name 'PnP Alert' --id 0x01007926A45D687BA842B947286090B8F67D --group 'PnP Content Types'

For more information about working with list- and site content types using the Office 365 CLI, see the documentation at aka.ms/o365-cli.

Manage navigation nodes

If your solution is provisioning a complete site, a part of the configuration will likely be setting up menu items. Proper navigation will help your users easily navigate between the different parts of your solution: whether they’re standard document libraries and lists or custom pages you created. In this version of the Office 365 CLI we added the ability to list available navigation nodes, remove a specific node or create a new one.

To list navigation nodes currently configured in the specified site’s top navigation bar, execute:

spo navigation node list --webUrl https://contoso.sharepoint.com/sites/team-a --location TopNavigationBar

To remove a specific node from the top navigation bar, execute:

spo navigation node remove --webUrl https://contoso.sharepoint.com/sites/team-a --location TopNavigationBar --id 2003

To add a new navigation node to the top navigation bar, execute:

spo navigation node add --webUrl https://contoso.sharepoint.com/sites/team-a --location TopNavigationBar --title About --url /sites/team-s/sitepages/about.aspx

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

Add web parts to modern pages

More and more organizations are switching to using modern pages. And it’s not surprising. Modern pages load faster than their classic counterparts, they are responsive by default and work in the mobile SharePoint app. With each update of Office 365, Microsoft is adding new capabilities to modern pages, including the recently completed of approval and page metadata.

There are a few differences between classic and modern pages. One of them is the lack of a fixed layout and web part zones. Instead, web parts are placed on canvas. This is required for the pages to be responsive, but the lack of a first party API complicates managing and provisioning web parts to pages. For this release of the Office 365 CLI, Yannick Plenevaux contributed a command to add web parts to modern SharePoint pages. To add a custom web part to the page, execute:

spo page clientsidewebpart add --webUrl https://contoso.sharepoint.com/sites/a-team --pageName page.aspx --webPartId 3ede60d3-dc2c-438b-b5bf-cc40bb2351e1

The command is pretty powerful and allows you to add both standard and custom web parts. Additionally, you can choose to which section, column and at which position on the page you want to add the web part.

For more information about adding web parts to modern pages using the Office 365 CLI, see the documentation at aka.ms/o365-cli.

Get information about modern page columns

As part of your provisioning logic, you might need to script updating existing modern pages. This could be a part of the logic to upgrade your solution or an automated way to change the composition of a number of modern pages. Before applying the upgrade, you would verify if the page is still in its original state and needs to upgraded or not. To do this, you would get information about page’s sections and columns. For this release of the Office 365 CLI, fellow SharePoint MVP - Rodrigo Romano contributed a command to get information about columns of the particular page section. To get this information, execute:

spo page column list --webUrl https://contoso.sharepoint.com/sites/team-a --name home.aspx --section 1

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

Update site properties

Sites in SharePoint help your organize your information into logical units, they define security boundaries but also the user experience used to present your data to users. As a part of provisioning, you might need to update some information about a site such as its title or description, or control its navigation. In this version of the Office 365 CLI, we’ve added the support to update some of the site’s properties.

To update site’s title, execute:

spo web set --webUrl https://contoso.sharepoint.com/sites/team-a --title Team-a

To hide site’s quick launch menu, execute:

spo web set --webUrl https://contoso.sharepoint.com/sites/team-a --quickLaunchEnabled false

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

Contributors

This release wouldn’t be possible without the help of (in alphabetical order) Yannick Plenevaux and Rodrigo Romano.

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

Work in progress

Recently, we’ve been working on a couple of things.

Setup script for the PnP SharePoint Starter Kit

Recently, 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. So far, we 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: