Office 365 CLI – Cross-platform Office 365 managment.

Today i’m gonna show you how to install the Office 365 CLI. but wait , why should i invest time in this if i have all these good cmdlets for my powershell in Windows ? Well first off, if you are using something else than Windows the Office 365 CLI will come in handy straight away, but another strong feature is that you can call the Office 365 CLI commands from any scripting language. Yeah you read that right, you can make a bash, powershell, python script and so on. This is also usefull if your team consist of devops with diffrent types of operating systems. With this CLI you can make the same script that works cross-platform. It also presist your connection to your tenant when authenticated. Pretty neat.

To install the Office 365 CLI type the following

npm i -g @pnp/office365-cli 

Now lets try to authenticate to our tenant. (Replace the URL with your sharepoint admin url)

o365 spo login 

This will return something like this: To sign in, use a web browser to open the page and enter the code C52LX32VC to authenticate. Now you will need to open a browser, enter the url and paste the code. This will authenticate your device.

Paste in the temporary code presented from the CLI

You now need to authenticate with a global admin account, and accept permissions requested by the CLI.

When your done you will be redirected to a message looking like this

Now lets give it a try, type in the following in your terminal.

o365 spo status

This should return something similar to this.


Remember, the Office 365 CLI persists connection information on your computer so you dont have to authenticate every time you run a script. Now your ready to mange your Office 365 tenant from almost any shell/scripting language, happy automation!

If you want to uninstall the Office 365 CLI and have already connected to your tenant you should logout of it or else the the login information will presist on your computer and you have to remove it manually.

o365 spo logout

To logout of our tenant (Replace the URL with your sharepoint admin url)

To uninstall the Office 365 CLI:

npm uninstall -g @pnp/office365-cli

Protip: For a complete set of commands go to

Protip2: to install the beta version:

npm install -g @pnp/office365-cli@next

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.