Skip to content

Commit

Permalink
Merge pull request #761 from reshmee011/GetTenantId
Browse files Browse the repository at this point in the history
Propose PnP PowerShell alternative to get tenant Id
  • Loading branch information
pkbullock authored Oct 27, 2024
2 parents 51d2920 + d8d40db commit fbed27b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
22 changes: 19 additions & 3 deletions scripts/aad-get-tenantid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugin: add-to-gallery

## Summary

These are 2 practical scripts I have to get Tenant ID from either a domain name or from a Subscriptionis ID.
These are practical scripts I have to get Tenant ID from either a domain name or from a Subscriptionis ID.

These are simple, but very useful to be combined in other scripts.

Expand Down Expand Up @@ -154,6 +154,22 @@ function Get-TenantIdFromSubscriptionId {
```
[!INCLUDE [More about PowerShell](../../docfx/includes/MORE-PS.md)]

# [PnP PowerShell](#tab/pnpps)

```powershell
param (
[Parameter(Mandatory = $true)]
[string] $domain
)
$adminSiteURL = "https://$domain-Admin.SharePoint.com"
Connect-PnPOnline -Url $adminSiteURL -Interactive -WarningAction SilentlyContinue
Get-PnPTenantId
```
[!INCLUDE [More about PnP PowerShell](../../docfx/includes/MORE-PNPPS.md)]

***

## Source Credit
Expand All @@ -165,7 +181,7 @@ Sample first appeared on [https://github.com/dkaaven/M365-Scripts](https://githu
| Author(s) |
|-----------|
| [Daniel Kåven](https://github.com/dkaaven)|

| [Reshmee Auckloo](https://github.com/reshmee011) |

[!INCLUDE [DISCLAIMER](../../docfx/includes/DISCLAIMER.md)]
<img src="https://m365-visitor-stats.azurewebsites.net/script-samples/scripts/aad-get-tenantid" aria-hidden="true" />
<img src="https://m365-visitor-stats.azurewebsites.net/script-samples/scripts/aad-get-tenantid" aria-hidden="true" />
18 changes: 16 additions & 2 deletions scripts/aad-get-tenantid/assets/sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@
""
],
"creationDateTime": "2024-10-14",
"updateDateTime": "2024-10-14",
"updateDateTime": "2024-10-27",
"products": [
"Azure"
],
"metadata": [
{
"key": "POWERSHELL",
"value": "7.2.0"
},
{
"key": "PNP-POWERSHELL",
"value": "1.11.0"
}
],
"categories": [
Expand All @@ -35,6 +39,12 @@
}
],
"authors": [
{
"gitHubAccount": "reshmee011",
"company": "",
"pictureUrl": "https://avatars.githubusercontent.com/u/7693852?v=4",
"name": "Reshmee Auckloo"
},
{
"gitHubAccount": "dkaaven",
"company": "",
Expand All @@ -43,7 +53,11 @@
}
],
"references": [

{
"name": "Want to learn more about PnP PowerShell and the cmdlets",
"description": "Check out the PnP PowerShell site to get started and for the reference to the cmdlets.",
"url": "https://aka.ms/pnp/powershell"
}
]
}
]

0 comments on commit fbed27b

Please sign in to comment.