I was installing the latest version (2.7) of the Office 365 CLI — if you haven’t tried it yet, you definitely should — and I started thinking "Hmm, I wonder if I could do a quick contribution for this?".

I absolutely love the Office 365 CLI and I think the team has done an amazing job with it. I even made a tiny contribution a while ago, but never got around to doing more.

Keep in mind that I have to study for two certification exams that I have scheduled over the next two days, I have to review my materials for Office 365 Saturday Redmond 2020, I have to prepare for the upcoming Toronto Citizen Developer User Group meeting, I have a web part that I need to finish with the help of , and I need to finish adding Graph integration to my PnP Calendar Control…

… but other than that, I have some spare time. I took a look at the list of to look for inspiration and found a request for a new command called .

Wait a minute, I know how to get the tenant ID! I use this trick all the time. And it doesn’t require any code or any tools to be installed.

So I thought I should at least share my trick for finding the tenant ID, and if I’m a good boy and do all my work today maybe I’ll treat myself and do a contribution to the Office 365 CLI.

Getting the Tenant ID

I found this trick over 3 years ago in a Stack Overflow discussion and, but it took a little playing around to get it working.

To get your tenant id, follow these steps:

  1. Start with your original tenant name. It should be in the form of [yourtenant] Do not use your custom domain name, use your original tenant name. If in doubt, use whatever comes before on your SharePoint Online site.
  2. Browse to[yourtenant] Note that you have to replace [yourtenant] with the tenant name you obtained in step 1. Make sure to keep the bit too. This URL is not authenticated, so you should be able to get to it from anywhere without logging in, so you can use something list Postman if you want, but a regular browser will do.
  3. You’ll get some JSON back. Don’t worry, you don’t need to speak JSONese, just look for whatever URL comes after "token_endpoint": . It should start with "
  4. Your tenant ID is the alphanumeric value immediately after " and before /oauth2/token",. For example, if you get this first line:
    "token_endpoint": "",

    your tenant ID will be ef32e188-30ce-4f80-8956-d95598788bdc

That’s it!


I know, I know, some of you will say "You can just go to the Azure Admin center and get the directory ID" as per Official Microsoft documentation, but it assumes that you have access to the Azure Admin center.

The way described in this post works regardless of your permissions, and does not need any tools to be installed on your computer, or any code.

I hope this helps?

Photo Credit

Image by Pexels from Pixabay


  • March 2, 2020: has an article which shows about 17 different ways to retrieve the tenant ID. Very cool!

  • March 2, 2020: has also written an article about this topic. Thanks Joseph!

  • March 2, 2020: kindly pointed out that he has a great article showing two more approaches to get your tenant ID.

  • March 1, 2020: Thanks to for reminding me that ShareGate has a web-based tool available at

  • March 1, 2020: If you want to use PowerShell to find your tenant ID, wrote in with this cool PowerShell script:

    $tenantID = (Invoke-WebRequest<TENANT_NAME>|ConvertFrom-Json).token_endpoint.Split('/')[3]

Microsoft MVP and PnP Team Member. Independent consultant. Certified SCRUM Master. SharePoint, Office 365 and Dynamics 365 are his favourite toys.

How can I help?

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