Office 365 CLI v1.3.0


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

Manage Office 365 on any platform

Office 365 CLI is a cross-platform CLI that allows you to manage various configuration settings of Office 365 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.

New version of Office 365 CLI - v1.3.0

Working through the conference season we’ve just published a new version of the Office 365 CLI. Once again, we’ve had no breaking changes so while just a minor SemVer update, we have some cool new commands and improvements. See for yourself.

Groupify sites

Office 365 Groups bring together a number of Office 365 capabilities to facilitate team collaboration and communication. Many organizations, who have been using Office 365 for some time now, already have an existing intranet based on SharePoint sites and the classic SharePoint experience. To help these organizations benefit from Office 365 Groups, without having to migrate their collaboration sites, Microsoft introduced the ability to create a new Office 365 Group for the existing site, process often referred to as ‘groupify’. At this moment, groupifying sites is possible only using the SharePoint APIs, but soon this capability will be also available in the SharePoint UI.

To groupify an existing site collection using the Office 365 CLI, execute:

spo site o365group set --siteUrl https://contoso.sharepoin.com/sites/team-a --alias team-a --displayName 'Team A'

While groupifying a site, there are a number of other arguments that you can specify like the classification of the site or whether the existing site welcome page should be retained or not.

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

Simplified deployment of SharePoint packages

When using the Office 365 CLI in his Continuous Integration/Deployment (CI/CD) setup for SharePoint Framework projects, fellow-MVP and a good friend Elio Struyf noticed that it’s inconvenient to add the solution package to the app catalog and deploy it in a single script. He proposed simplifying the process by extending the existing CLI commands.

Following Elio’s suggestions, when you execute the spo app add command, the CLI will return the ID of the newly added solution package (or all available information if you set the output mode to json). Additionally, when using the spo app deploy command to deploy a solution package, you can now not only specify the package to be deployed using its ID, but also using its name, which makes it easier to use in automation scenarios:

spo app deploy ---name solution.sppkg

For more information about deploying SharePoint solution packages using the Office 365 CLI, see the documentation at aka.ms/o365-cli.

Manage Azure AD group settings

Azure Active Directory offers administrators a number of advanced settings to manage their tenants. These settings are exposed through group settings and group settings templates and allow administrators to define the information classification in their tenant, control guess access or naming policies to name a few. Using the Office 365 CLI, you can explore group setting templates and manage group settings in your tenant.

For example, to define information classification in your tenant using the Office 365 CLI, execute:

graph groupsetting add --templateId 62375ab9-6b52-47ed-826b-58e47e0e304b --UsageGuidelinesUrl https://contoso.sharepoint.com/sites/compliance --ClassificationList 'HBI, MBI, LBI, GDPR' --DefaultClassification MBI

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

Copy files

Once in a while you might need to copy files stored in SharePoint from one location to another. If it’s just a few files, doing it manually might be an option. But with tens or hundreds of files, the job would quickly become tedious. To help you script copying files in your Office 365 tenant, Velin Georgiev implemented support for copying files using the Office 365 CLI.

To copy a file using the Office 365 CLI, execute:

spo file copy --webUrl https://contoso.sharepoint.com/sites/test1 --sourceUrl /Shared%20Documents/sp1.pdf --targetUrl /sites/test2/Shared%20Documents/

Using the spo file copy command you can copy files between the folders, document libraries or sites.

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

Manage folders

Many organizations and users organize their documents in folders. When the information architecture changes, it might be necessary to adjust the folder structure accordingly. To manage folders using the Office 365 CLI, Velin Georgiev implemented a set of commands that support everything from listing folders in a specific document library to renaming or copying folders.

For example, to see all folders in a document library, execute:

spo folder list --webUrl https://contoso.sharepoint.com/sites/project-x --parentFolderUrl '/Shared Documents'

To copy a folder to a different site, execute:

spo folder copy --webUrl https://contoso.sharepoint.com/sites/test1 --sourceUrl /Shared%20Documents/MyFolder --targetUrl /sites/test2/Shared%20Documents/

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

Apply theme

To help organizations control the look and feel of modern sites, Microsoft released the support for modern themes. If your organization has an existing intranet built on top of Office 365, the chances are, that it existed before the modern themes were made available. As a result, you might have a number of sites, to which you might need to apply a modern theme. For these release, Paweł Hawrylak implemented a command to apply a theme to an existing site.

To apply a theme to an existing site using the Office 365 CLI, execute:

spo theme apply --name Contoso-Blue --webUrl https://contoso.sharepoint.com/sites/project-x

This command is invaluable if you have a number of sites and would like to update their theme in bulk.

For more information about deploying SharePoint solution packages using the Office 365 CLI, see the documentation at aka.ms/o365-cli.

Default themes, yes or no

If your organization is using modern themes, you might want to control whether users should be able to use both custom themes provided by your organizations as well as the standard SharePoint themes, or only custom themes. This setting can be controlled using the SharePoint API. In this release, Paweł Hawrylak implemented a set of commands to manage modern themes’ settings. To see, if users in your tenant can use standard SharePoint themes or not, execute:

spo hidedefaultthemes get

A false response indicates, that users can use both custom and standard SharePoint themes.

To disallow using the standard SharePoint themes, execute:

spo hidedefaultthemes set --hideDefaultThemes true

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

Send e-mail

When implementing automation scenarios, you might need to notify a specific individual or a group of people via e-mail. To make this possible, you can now send an e-mail on behalf of the user working with the Office 365 CLI. To send an e-mail execute:

graph user sendmail --to chris@contoso.com --subject 'DG2000 Data Sheets' --bodyContents 'The latest data sheets are in the team site'

The command is pretty flexible, allowing you to send both plain-text and HTML e-mails and either specify the e-mail contents inline or load them from the specified file.

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

Stay up-to-date

Regularly, we’re releasing new versions of the Office 365 CLI. Each new version contains new commands and improvements giving you more power and flexibility. To help you stay up-to-date with the new releases, Paweł Hawrylak implemented a notification that lets you know when a new version of the Office 365 CLI is available.

Contributors

This release wouldn’t be possible without the help of (in alphabetical order) Velin Georgiev, Paweł Hawrylak and Elio Struyf.

Thank you all for the time you chose to spend on the Office 365 CLI and your help to advance it. It’s a real pleasure to work with you.

What’s next

Over the last few weeks we’ve been discussing and researching 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?

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.

Managing SharePoint Framework projects

What if you could use the Office 365 CLI not only to manage your Office 365 tenant but also to improve the developer experience of your Office 365 solutions?

Another area, that we’ve been researching recently, is the ability for the Office 365 CLI to manage your SharePoint Framework projects. SharePoint Framework is a popular development model backed by a vibrant community and there are some great opportunities for the CLI to improve how you build solutions. We had some delay but are still going forward with the research and hope to have something to show you relatively fast, so stay tuned for updates.

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: