Loading...

Get started with CLI Microsoft 365 for Power Platform people

Get started with CLI Microsoft 365 for Power Platform people

tl;dr

CLI for Microsoft 365 is an amazing tool to manage your Microsoft 365 tenant and SPFx projects. But did you know, that also people working with Power Platform can massively benefit from using it?

To convince you, I chose a use case, that will probably relate to lots of people, but please be aware, that CLI for Microsoft can do so much more!

Use case: App registrations in Azure Active Directory

Very often when working with Power Automate or Power Apps, we want to leverage the power of Microsoft Graph API. To do so, we need to authenticate against Graph using Azure Active Directory (Azure AD) and register an application in the Azure portal at portal.azure.com. Depending on permissions, redirect URI, secret etc. we need to perform several steps and take note of certain outputs. Wouldn’t it be nice if the entire app registration process was rather a one line command that automatically outputs the values we need?

After installing CLI Microsoft 365 and logging in, all we need to do is

m365 aad app add `
--name 'myApp001' `
--redirectUris 'https://global.consent.azure-apim.net/redirect' `
--platform web `
--withSecret `
--apisDelegated 'https://graph.microsoft.com/People.Read.All' `
--grantAdminConsent `

What this does is registering an application with the following parameters:

  1. Displayname of the app is myApp001
  2. Redirect URI is https://global.consent.azure-apim.net/redirect that is what you need for custom connectors in Power Platform
  3. It does create a secret (and will output it)
  4. It has delegated permissions for People.Read.All on Graph API
  5. Admin consent is already granted

If we run this command (and we can do this as one-line as well without the backticks ` at the end of each line)

m365 aad app add --name 'myApp001' --redirectUris 'https://global.consent.azure-apim.net/redirect' --platform web --withSecret --apisDelegated 'https://graph.microsoft.com/People.Read.All' --grantAdminConsent

we get the following output:

{
"appId": "164298a8-504c-4234-a43a-XXXXXXXXXXXX",
"objectId": "02b7577e-4d6b-478a-b34c-XXXXXXXXXXXX",
"tenantId": "b469e370-d6a6-45b5-928e-XXXXXXXXXXXX",
"secrets": [
{
"displayName": "Default",
"value": "XXXXX~5FUlgaKtYEAJ-XXXXX~DWsnj6yerYATXXX"
}
]
}

which means, that we can use appId and the value of the secret in our custom connector or in the HTTP action of our Power Automate flow.

Get started with CLI for Microsoft 365

If you now want to try this out as well, you need to follow these steps:

  1. Install node.js With node.js comes npm and we will install CLI for Microsoft 365 with npm. If you don’t have npm or node.js installed:
    • Open node.js
    • Select 18.12.1 LTS
    • Install node.js
  2. Install CLI for Microsoft 365
    • Open a terminal of your choice, I use the built-in terminal of Visual Studio Code
    • Type npm i -g @pnp/cli-microsoft365 to install CLI for Microsoft 365 globally
  3. Login
    • To login, type m365 login
    • You will see a message like this: "To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code BAVUYWLZ3 to authenticate." - Do exactly that. Copy that code, open the URL and paste the code.
    • Select Next

device code login

Now log into the tenant you want to connect with using your username and password (+ optional MFA)

login

You can close the https://login.microsoftonline.com/common/oauth2/deviceauth page again

đź’ˇ Until you type m365 logout, you will stay logged in.

  1. Try out to register an app

Now lets see if that worked! Register your own application and validate in the Azure portal.

  1. Tell people on twitter about it - https://twitter.com/intent/tweet?text=I%20used%20%23CLIMicrosoft365%20to%20register%20an%20app%20in%20%23AzureAD%20and%20it%20worked%20like%20a%20charm%21%20-%20%0D%0A%0D%0ARead%20%40LuiseFreese%20s%20blog%20post%20about%20it%20here%3A+https%3A%2F%2Fm365princess.com%2Fblogs%2Fcli-microsoft-365-power-platform

Feedback and what’s next?

If you liked this experience, maybe you want to dip your toes even a bit further into CLI for Microsoft 365 - here is why you should absolutely consider that:

  • it’s open-source and we are all here to learn
  • it’s an amazing project with the most awesome contributors
  • it has a lot of super-helpful commands around Power Apps, Power Automate, and more in Power Platform - more to come! Any ideas?

Let me know on twitter :-)

Published on:

Learn more
Luise Freese: Consultant & MVP
Luise Freese: Consultant & MVP

Recent content on Luise Freese: Consultant & MVP

Share post:

Related posts

Microsoft Teams: Users can join town hall and webinars using Public Switched Telephone Network (PSTN) codes

Microsoft Teams will soon allow organizers and presenters to join town halls, webinars, and structured meetings using PSTN codes. This feature...

2 days ago

Microsoft Teams: CVI coordinates enables presenters to join Town hall via VTC devices

Microsoft Teams will soon allow organizations to join and present in Teams town halls using their own video conferencing devices via Cloud Vid...

2 days ago

Microsoft PowerPoint: Reference up to 5 files when creating a presentation with Microsoft 365 Copilot

Microsoft PowerPoint users with a Microsoft 365 Copilot license can reference up to 5 files when creating a presentation. This feature will be...

2 days ago

Microsoft Defender for Office 365: Agentic AI – powered Submissions Response for Improved Result Explainability

We are introducing intuitive responses powered by Agentic AI for admin-submitted messages analyzed by Microsoft. Product Microsoft Defender fo...

2 days ago

Microsoft Teams: Teams Town hall screen management privileges in Teams Rooms on Windows

When the Teams Room on Windows is a co-organizer or a presenter in a town hall, privileges can be granted to start or end the event, manage wh...

2 days ago

Microsoft Viva: Viva Learning – Academy auto-save and drafting functionality

Changes you make to new, draft, or published LPs are now saved automatically in the background. In addition, your updates are now saved in a d...

2 days ago

Microsoft Copilot (Microsoft 365): @mention your Researcher in Copilot Chat

Easily chat with your Researcher in Copilot Chat. Product Release phase General Availability Release date May CY2025 Platform Web Cloud Instan...

2 days ago

Microsoft Viva: Anonymous comments in Engage events

Organizers & attendees can now post comments anonymously during Engage events—just like anonymous questions. When enabled by the organize...

2 days ago

SharePoint: SharePoint Dynamic Web Part for FAQ

Dynamic Web Part for FAQ helps SharePoint content owners effortlessly keep their content fresh and relevant. Powered by AI, it automatically c...

2 days ago

Microsoft Viva: Viva Learning – Notification Settings

Admins can now enable/disable all learning-related notifications from a centralized settings page. Product Microsoft Viva Release phase Genera...

2 days ago
Stay up to date with latest Microsoft Dynamics 365 and Power Platform news!
* Yes, I agree to the privacy policy