What is CLI for Microsoft 365 and How to Install it ?

Yunus Emre Araç
3 min readMay 17, 2023

Referance: https://www.yunusemrearac.com/2023/05/17/microsoft-365-icin-cli-nedir-ve-nasil-kurulur/

Hello friends, today I am here with a feature that will delight multi-platform users, especially in the Microsoft 365 world. In fact, although this feature has been available since 2020, I was surprised that it was not considered much, and I felt the need to make a statement on this subject.

Now, if we talk about the SharePoint ecosystem first, if you want to develop or work on the onprem versions of this product, it cannot even be done on a windows operating system. You needed a windows server with Sharepoint installed. In this case, it was a very difficult situation especially for other software developers in the sector and those who wanted to develop in this field. The fact that development had such a detailed process and not everyone could reach it also affected the number of developers in this area.

After Microsoft 365 came into our lives, it was now possible for us to develop on our own computers with client side technologies by using the PnPJS library without the need for a windows server to develop on this side. In addition, these improvements could be made on computers other than windows.

But besides these, you could only use windows machines, especially for applications such as PnP Powershell or SharePoint Management Shell. In this case, there was a dependency on macOS or linux operating systems, such as connecting to a windows virtual machine or a different device.

In order to solve all these problems and to make Microsoft 365 products a platform independent product, a CLI structure has emerged so that you can manage these products seamlessly in each of them, whether you use windows, macOS, linux operating systems.

The CLI structure for Microsoft 365 allows you to use them like PnP PowerShell and SharePoint Management PowerShell, regardless of cmd, powershell, bash or zsh.

You can also access the official website of this product at https://pnp.github.io/cli-microsoft365/.

In order to install this product, NodeJS must be installed on your device and a minimum version of 18 or higher must be installed.

You can then install the “CLI for Microsoft 365” using the following NPM command.

npm install -g @pnp/cli-microsoft365

If you are using yarn, you can also use the following command to install it using yarn.

yarn global add @pnp/cli-microsoft365

If you already have CLI installed on your computer, you can check which version is installed with the command below.

m365 version

If the installed version on your computer belongs to an old version, you can use the command below to update it to the latest version.

npm install -g @pnp/cli-microsoft365@latest

The following command can be used to remove it from your computer.

npm uninstall -g @pnp/cli-microsoft365

After the installations are complete, you can connect to Microsoft 365 with the code below.

m365 login

After this process, as you will see in the redirect, it will be enough to go to the “https://microsoft.com/devicelogin" address on your computer browser and complete your login process with the code given at this address.

After this stage, you can control and manage the Microsoft 365 product you want from here.



Yunus Emre Araç

Technology Product Manager of Corporate Applications at ING | Old Microsoft Student Partners Lead | İnönü Üniv. Bilg. Müh. | İAU Bilg. Müh. Tezli Yüksek Lisans