Office 365 CLI version 2 has been released

SharePoint team

We have just released a new major version of the Office 365 CLI that simplifies managing Office 365 tenants and SharePoint Framework projects on any platform. With one simple login you can now connect to any service in Office 365 and thanks to support for throttling and compression, Office 365 CLI will more reliable handle your scripts at scale.

Manage Office 365 and SharePoint Framework projects on any platform

Office 365 CLI is a cross-platform command-line tool that allows you to manage settings of Office 365 tenants and SharePoint Framework projects no matter which operating system or shell you use. Additionally, it combines the management of the different services in Office 365 in a single consistent interface following other familiar tools such as the Azure CLI, npm or git.

New major version

Office 365 CLI v2 introduces simplified login and command names as well as a number of improvements that increase its reliability and performance.

Grouping per service vs. grouping per API

In the previous version of the Office 365 CLI, commands were grouped by the API they used to connect to the corresponding service in Office 365. For example, Microsoft Teams commands would start with `graph teams`, because they used the Microsoft Graph but Microsoft Flow commands would start with `azmgmt flow` because they were built using the Azure Management API. This naming convention required the user to know how we implemented the particular command.
To make it easier for you to work with the CLI, we removed the API name from the command name. In Office 365 CLI v2 all command names start with the name of the service to which they belong. Check out the docs at aka.ms/o365cli for the updated list of commands.

One login

In Office 365 CLI v1, we let you log in separately to each API. You would execute `spo login` to connect to SharePoint or `graph login` to connect to the Microsoft Graph. Theoretically, it gave you the flexibility to use different accounts with different services. In practice however, no one really used the CLI that way. So in Office 365 CLI v2, we decided to move away from the per-service/-API log in and have one login in the CLI that automatically takes care of the authorization when switching between services.
To login in Office 365 CLI v2, all you need to do is to run the `login` command. Once you’re signed in, you can start using all commands in the CLI.

Auto-detect SharePoint URL

Comparing to other Office 365 services, SharePoint Online has a unique URL on every tenant. Where the Microsoft Graph, for example, is always available at `https://graph.microsoft.com`, SharePoint needs to be called using its unique URL, like `https://contoso.sharepoint.com`.

In the previous version of the Office 365 CLI, when logging in to SharePoint Online, you would specify the URL of your tenant to which you wanted to connect, eg. `spo login https://contoso.sharepoint.com`. If you wanted to use admin-level commands, you had to specify the tenant admin URL instead or these commands would fail, eg. `spo login https://contoso-admin.sharepoint.com`.
In Office 365 CLI v2 we simplified all this. After logging in to your Office 365 tenant using the `login` command, the CLI will automatically detect the URL of SharePoint Online and automatically switch between the root site or the tenant admin URL depending on the commands you use.
While this approach should work in most cases, it could lead to undesired results when you, for example, work with a multi-geo tenant and want to manage specific geography. In such a case you can use the `spo set –url https://contosoeur.sharepoint.com` command to specify the URL of the geography that you want to manage.

New commands and improvements

Aside from big architectural changes, we shipped quite a few new commands for SharePoint, Teams, Flow, Office 365 Groups and the Microsoft Graph as well as some improvements. Check out the release notes for a full list of what has changed.

Contributors

This release wouldn’t be also possible without the help of (in alphabetical order)

as well as all other contributors who helped with previous releases of the Office 365 CLI. There wouldn’t be a v2 without the v1, which you helped to build. Thank you all so much for the time you chose to spend on the Office 365 CLI!

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.

“Sharing is caring”

 


SharePoint Team, Microsoft – 11th of September 2019

Feedback usabilla icon