Cross-Platform Administration for Office 365 with Office 365 CLI Tool

Office 365 Change Management

Office 365 CLI (“Command-Line Interface”) is a new open source tool that was incubated within the Office Developer Patterns and Practices (Office Dev PnP for short) group. The purpose of the tool is to allow administrators to view and change settings in Office 365, although for now, the tool is limited to SharePoint Online only.



Currently, the tool can be used to connect with a specific SharePoint Online site, to change and review settings for CDN, SharePoint customizations known as apps (or add-ins depending which documentation you’re following), and storage settings. Although this leaves a lot to be desired, it’s still a good start as the tool is cross-platform and can be used in Linux and macOS as well.

Installing Office 365 CLI

The tool is distributed as a pre-compiled package and can be installed easily with the npm tool. This is a package manager, which is not installed by default in Windows or other OS’s. You first need to either download npm or install it through your operating system’s package manager.

I’m using a virtual machine with Ubuntu Linux and it did not have npm installed with the basic installation. The quickest way to install npm is to execute the following command. Note that I’m using sudo to elevate my privileges for the installation to succeed:

sudo apt install npm

This takes a minute or so to install. You can try out if npm works now with:

sudo npm --version

You should see the version number. For me, it is 3.5.2.

I can now install Office 365 CLI by simply fetching the latest release via npm:

npm i -g @pnp/office365-cli

The ‘i’ parameter is a shorthand for install and -g is a shorthand for global. After installation succeeds, the tool can be executed by typing


I have to admit, I felt a bit funny when first initiating this command on a Linux shell as it so strongly underlines how the world is changing with regards to Microsoft’s stance and technologies.

Using Office 365 CLI to Connect to SharePoint Online

Using the tool is very straightforward. Once the tool starts, you can type help to get a list of all available commands. For now, there are only a few commands available but I expect this list to grow in the coming weeks and months. As the tool is open sourced, anyone can push their own ideas to the team or implement new functionality to be considered as part of the tool. See more information about the process here.



To connect to my SharePoint Online admin tenant, I use the following command:

spo connect https://{tenant-name}

This initiates a clever authentication approach, where I use in a browser to complete the authentication. I’ve recorded a screen capture of this process:

Office 365 CLI SPO Connect


Once I ask for the connection, I receive a one-time passcode to use. Don’t worry, the one you’re seeing above is already used. From the browser side, this is how it looks:

Office 365 CLI finalizing authentication

I can now start querying for information from my tenant. With spo status, I can easily retrieve the access token and refresh token for authentication in my own apps.


Office 365 CLI spo status


With spo app list, I can view which apps have been deployed to my App Catalog within the SharePoint Online tenant. In my test tenant I only have one.

Office 365 CLI SPO App List


To further query this app, I can type spo app get -i and append the app id:

Office 365 CLI SPO App Get


Other things the tool is capable of doing include adding and deploying apps, retracting and uninstalling apps, upgrading existing apps, configuring CDN settings, and retrieving and setting storage options for the tenant.

Thoughts on Using Office 365 CLI

As the installation is so easy, I see this tool as highly useful even in its infancy for IT Pros and SharePoint Online admins. The ability to quickly verify settings in SharePoint Online and the ability to install new custom apps in a more controlled fashion is a very welcomed addition. Granted, we can still use PowerShell and the fabulous Office Dev PnP cmdlets but they are more problematic when not using Windows where PowerShell is natively baked in.



I recommend readers to keep a close eye on how this tool evolve, and to be vocal about your needs, possible bugs you might find, and provide feedback to the team building it.