Skip to content

Commit

Permalink
Commit from GitHub Actions (Generate Site)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkbullock committed Oct 23, 2024
1 parent f09fd0f commit 22b495b
Show file tree
Hide file tree
Showing 14 changed files with 8,309 additions and 7,411 deletions.
312 changes: 312 additions & 0 deletions aad-get-tenantid/README.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,312 @@
<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html lang="en">

<head>
<meta charset="utf-8">
<title>Get Tenant ID | PnP Samples </title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" "="">
<meta name="title" content="Get Tenant ID | PnP Samples ">
<meta name="generator" content="docfx 2.56.7.0">
<meta name="description" content="A sample gallery of scripts to manage all things Microsoft 365.">

<!-- Social Media -->
<meta property="og:locale" content="en_GB">
<meta property="og:title" content="Get Tenant ID | PnP Samples ">
<meta property="og:type" content="website">
<meta property="og:url" content="https://pnp.github.io/script-samples">
<meta property="og:image" content="https://pnp.github.io/script-samples/assets/social-media-screenshot.png">
<meta property="og:image:alt" content="Screenshot example of the PnP Script Samples Site">
<meta property="og:site_name" content="PnP Script Samples">
<meta name="msvalidate.01" content="04EFEDA66EC42C08A1247C979E2F9ADD">
<meta property="og:description" content="A sample gallery of scripts to manage all things Microsoft 365.">

<link rel="shortcut icon" href="https://c.s-microsoft.com/favicon.ico?v2">
<link rel="stylesheet" href="../styles/docfx.vendor.css">
<link rel="stylesheet" href="../styles/docfx.css">
<link rel="stylesheet" href="../styles/main.css">
<link rel="stylesheet" href="../styles/extra.css">
<link rel="stylesheet" href="../styles/filter.css">
<link rel="stylesheet" href="../styles/site.css">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<meta property="docfx:navrel" content="../toc.html">
<meta property="docfx:tocrel" content="../toc.html">


<meta property="docfx:newtab" content="true">
<script type="text/javascript">
(function(c,l,a,r,i,t,y){
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "8j6pedl344");
</script>
</head> <body data-spy="scroll" data-target="#affix" data-offset="120">
<div id="wrapper">
<header>

<nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
<div class="container">
<div class="github-mark">
<a href="https://github.com/pnp/script-samples" title="Go to repository">
<div class="github-wrapper">
<div class="github-icon">
<img src="https://pnp.github.io/script-samples/assets/icons/github-light-64px.png" alt="GitHub Icon Image">
</div>
<div class="github-repository">
<span>GitHub</span>
<ul class="github-facts">
<li>
<i class="fa fa-code-fork" aria-hidden="true"></i>
<span class="github-forks"></span>
</li>
<li>
<i class="fa fa-star-o" aria-hidden="true"></i>
<span class="github-stars"></span>
</li>
</ul>
</div>
</div>
</a>
</div>
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="../index.html">
<img id="logo" class="svg" src="../assets/logo.svg" alt="">
</a> </div>
<div class="collapse navbar-collapse" id="navbar">
<form class="navbar-form navbar-right" role="search" id="search">
<div class="form-group">
<label class="glyphicon glyphicon-search" for="search-query"></label>
<input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
</div>
</form>
</div>
</div>
</nav> </header>
<div role="main" class="container body-content hide-when-search">
<div class="article row grid">
<div class="col-md-12">
<article class="content wrap" id="_content" data-uid="">
<div class="contribution-panel mobile-hide pull-right">
<a href="https://github.com/pnp/script-samples/blob/main/scripts/aad-get-tenantid/README.md/#L1" title="Improve this Doc" class="improve-doc-lg"><i class="glyphicon glyphicon-pencil"></i></a>
</div>
<h1 id="get-tenant-id">Get Tenant ID</h1>

<h2 id="summary">Summary</h2>
<p>These are 2 practical scripts I have to get Tenant ID from either a domain name or from a Subscriptionis ID.</p>
<p>These are simple, but very useful to be combined in other scripts.</p>
<div class="tabGroup" id="tabgroup_CeZOj-G++Q">
<ul role="tablist">
<li role="presentation">
<a href="#tabpanel_CeZOj-G++Q_ps" role="tab" aria-controls="tabpanel_CeZOj-G++Q_ps" data-tab="ps" tabindex="0" aria-selected="true">PowerShell (Domain)</a>
</li>
<li role="presentation">
<a href="#tabpanel_CeZOj-G++Q_ps1" role="tab" aria-controls="tabpanel_CeZOj-G++Q_ps1" data-tab="ps1" tabindex="-1">PowerShell (Subscription)</a>
</li>
</ul>
<section id="tabpanel_CeZOj-G++Q_ps" role="tabpanel" data-tab="ps"><button class="article-clipboard" title="Copy to clipboard" data-toggle="tooltip" data-placement="top" data-clipboard-target="section[id^='tabpanel'][data-tab='ps'] pre">
<span class="glyphicon glyphicon-copy" aria-hidden="true"></span>
<span class="article-clipboard__message done">Copied</span>
</button>

<pre><code class="lang-powershell">

function Get-TenantIdFromDomain {
&lt;#
.SYNOPSIS
Get the tenant ID for any Domain.

.DESCRIPTION
Will check and return the tenant ID for any domin, or return $false if no ID is found.

.PARAMETER domain
Any domain name, ex. domain.com

.INPUTS
domain name: domain.com

.OUTPUTS
String or boolean False.

.EXAMPLE
Get-TenantIdFromDomain domain.com
Get-TenantIdFromDomain -domain domain.com
&quot;domain.com&quot; | Get-TenantIdFromDomain

.NOTES
FileName: Get-TenantIdFromDomain.psm1
Author: Daniel Kåven
Contact: @dkaaven
Created: 2022-03-25
Updated: 2024-10-13
Version History:
1.0.0 - (2022-03-25) Script created
1.1.0 - (2024-06-20) Added check for missing domain
1.2.0 - (2024-08-13) Added ability to get data from Pipeline

#&gt;

param(
[CmdletBinding()]
[parameter(
Mandatory = $true,
Position = 0,
HelpMessage = &quot;The domain name of the target tenant.&quot;,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true
)]
[String]$domain
)

# Check if tenant exists
try {
$request = Invoke-WebRequest -Uri https://login.windows.net/$domain/.well-known/openid-configuration
}
catch {
if ($null -eq $request) {
return $false
} else {
Write-Error $_
}
}

# Return tenant ID
$data = ConvertFrom-Json $request.Content
$result = $data.token_endpoint.split('/')[3]
return $result
}

</code></pre>
<div class="highlight-tool">
<p>Check out the <strong>PowerShell</strong> to learn more at: <a href="https://learn.microsoft.com/powershell">PowerShell Documentation | Microsoft Learn</a></p>
</div>
</section>
<section id="tabpanel_CeZOj-G++Q_ps1" role="tabpanel" data-tab="ps1" aria-hidden="true" hidden="hidden"><button class="article-clipboard" title="Copy to clipboard" data-toggle="tooltip" data-placement="top" data-clipboard-target="section[id^='tabpanel'][data-tab='ps1'] pre">
<span class="glyphicon glyphicon-copy" aria-hidden="true"></span>
<span class="article-clipboard__message done">Copied</span>
</button>

<pre><code class="lang-powershell">
function Get-TenantIdFromSubscriptionId {
&lt;#
.SYNOPSIS
Get the tenant ID from an Azure Subscription ID.
.DESCRIPTION
Will check and return the tenant ID for an Azure Subscription ID or return $false if no ID is found.
Inspired from [Jos Lieben @ lieben.nu](https://www.lieben.nu/liebensraum/2020/08/get-tenant-id-using-azure-subscription-id/)

.PARAMETER subscriptionId
The Azure Subscription ID to check.

.INPUTS
Azure Subscription Id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

.OUTPUTS
String or boolean False.

.EXAMPLE
Get-TenantIdFromSubscriptionId xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Get-TenantIdFromSubscriptionId -subscriptionId xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | Get-TenantIdFromSubscriptionId

.NOTES
FileName: Get-TenantIdFromSubscriptionId.psm1
Author: Daniel Kåven
Contact: @DKaaven
Created: 2024-08-06
Updated: 2024-08-06
Version history:
1.0.0 - (2024-08-06) Script created
#&gt;
param (
[CmdletBinding()]
[Parameter(
Mandatory = $true,
Position = 0,
HelpMessage = &quot;The Azure Subscription ID&quot;,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true
)]
[Alias(&quot;subId&quot;)]
[String]$subscriptionId
)
# Check Subscription ID format
$guidPattern = &quot;^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$&quot;
if ($subscriptionId -notmatch $guidPattern) {
Write-Error &quot;$subscriptionId is not a valid Azure Subscription ID.&quot;
return $false
}
$response = try {(Invoke-WebRequest -UseBasicParsing -Uri &quot;https://management.azure.com/subscriptions/$($subscriptionId)?api-version=2015-01-01&quot; -ErrorAction Stop).BaseResponse} catch { $_.Exception.Response }
$stringHeader = $response.Headers.ToString()
$tenantId = $stringHeader.SubString($stringHeader.IndexOf(&quot;login.windows.net&quot;)+18,36)

# Check if it exist or return false
if ($tenantId -match $guidPattern) {
return $tenantId
}
else {
return $false
}

}

</code></pre>
<div class="highlight-tool">
<p>Check out the <strong>PowerShell</strong> to learn more at: <a href="https://learn.microsoft.com/powershell">PowerShell Documentation | Microsoft Learn</a></p>
</div>
</section>
</div>
<h2 id="source-credit">Source Credit</h2>
<p>Sample first appeared on <a href="https://github.com/dkaaven/M365-Scripts">https://github.com/dkaaven/M365-Scripts</a></p>
<h2 id="contributors">Contributors</h2>
<table>
<thead>
<tr>
<th>Author(s)</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="https://github.com/dkaaven">Daniel Kåven</a></td>
</tr>
</tbody>
</table>
<h2 id="disclaimer">Disclaimer</h2>
<p><strong>THESE SAMPLES ARE PROVIDED <em>AS IS</em> WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.</strong></p>
<img src="https://m365-visitor-stats.azurewebsites.net/script-samples/scripts/aad-get-tenantid" aria-hidden="true">
</article>
</div>
</div>
</div>

<footer>
<div class="grad-bottom"></div>
<div class="footer">
<div class="container">
<span class="pull-right">
<a href="#top">Back to top</a>
</span>
<span>Script Samples<br>Generated by <strong><a href='https://dotnet.github.io/docfx' alt='Doc FX Website'>DocFX</a></strong> with <strong><a href='https://ovasquez.github.io/docfx-material' alt='DocFx Material Theme'>Material UI</a></strong></span>

<!-- <img src="https://telemetry.sharepointpnp.com/@pnp.github.io/index/" alt="spacer"> -->
</div>
</div>
</footer> </div>

<script type="text/javascript" src="../styles/docfx.vendor.js"></script>
<script type="text/javascript" src="../styles/docfx.js"></script>
<script type="text/javascript" src="../styles/main.js"></script>

<script type="text/javascript" src="../styles/clipboard.min.js"></script>
<script type="text/javascript" src="../styles/isotope.pkgd.min.js"></script>
<script type="text/javascript" src="../styles/loadsamples.js"></script>
<script type="text/javascript" src="../styles/filtersamples.js"></script>

</body>
</html>
Binary file added aad-get-tenantid/assets/example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added aad-get-tenantid/assets/preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions aad-get-tenantid/assets/sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[
{
"name": "aad-get-tenantid",
"source": "pnp",
"title": "Get Tenant ID",
"shortDescription": "These are 2 practical scripts to get Tenant ID from either a domain name or from a Subscriptionis ID.",
"url": "https://pnp.github.io/script-samples/aad-get-tenantid/README.html",
"longDescription": [
""
],
"creationDateTime": "2024-10-14",
"updateDateTime": "2024-10-14",
"products": [
"Azure"
],
"metadata": [
{
"key": "POWERSHELL",
"value": "7.2.0"
}
],
"categories": [
"Report",
"Security"
],
"tags": [
"<Cmdlets-Used>"
],
"thumbnails": [
{
"type": "image",
"order": 100,
"url": "https://raw.githubusercontent.com/pnp/script-samples/main/scripts/aad-get-tenantid/assets/preview.png",
"alt": "Preview of the sample AAD-Get-TenantID"
}
],
"authors": [
{
"gitHubAccount": "dkaaven",
"company": "",
"pictureUrl": "https://github.com/dkaaven.png",
"name": "Daniel Kåven"
}
],
"references": [

]
}
]
12 changes: 11 additions & 1 deletion cmdusage.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ <h1 id="report-of-samples-command-usage">Report of Samples Command Usage</h1>
<td style="text-align: center;">Get-CLIValue, ConvertFrom-Json, Get-AADPermission, Where-Object, Write-Host, Select-Object, Format-List, Write-Warning, Write-Error, Get-MgServicePrincipal</td>
</tr>
<tr>
<td><a href="aad-get-tenantid/README.html">Get Tenant ID</a></td>
<td style="text-align: center;"></td>
<td style="text-align: center;">Get-TenantIdFromDomain, Invoke-WebRequest, Write-Error, ConvertFrom-Json, Get-TenantIdFromSubscriptionId</td>
</tr>
<tr>
<td><a href="aad-grant-serviceprincipal-api-permissions/README.html">Grant Managed Identity permissions to audit and cleanup SPFx App Principal permissions</a></td>
<td style="text-align: center;">Connect-MgGraph, Connect-PnPOnline, Get-PnPSite, Get-PnPSiteCollectionAppCatalog, Get-PnPTenant, Get-PnPTenantAppCatalogUrl, Grant-PnPAzureADAppSitePermission</td>
<td style="text-align: center;">System-Managed, site-level, Set-ManagedIdentityAPIPermissions, Set-SiteAppCatalogPermissions, tenant-level, Export-MsIdAppConsentGrantReport, Import-Module, Write-Host, Get-MgServicePrincipal, ForEach-Object, Where-Object, New-MgServicePrincipalAppRoleAssignment</td>
Expand Down Expand Up @@ -403,6 +408,11 @@ <h1 id="report-of-samples-command-usage">Report of Samples Command Usage</h1>
<td style="text-align: center;">Get-AdminPowerApp, New-Object, Export-Csv</td>
</tr>
<tr>
<td><a href="powerapps-get-all-bootstrap-icons/README.html">Get all Bootstrap Icons to use in your powerapps</a></td>
<td style="text-align: center;"></td>
<td style="text-align: center;">Invoke-WebRequest, Write-Host, Write-Error, Read-Host, Add-Type, Set-Content, Remove-item</td>
</tr>
<tr>
<td><a href="powerapps-get-app-users-list-csv/README.html">Export all PowerApps details and its Role assignments from Tenant in CSV format</a></td>
<td style="text-align: center;"></td>
<td style="text-align: center;">pre-release, Install-Module, Add-PowerAppsAccount, write-host, Get-PowerAppRoleAssignment, New-Object, Add-Member, Export-Csv</td>
Expand Down Expand Up @@ -1667,7 +1677,7 @@ <h3 id="sharepoint-online-management-shell-usage">SharePoint Online Management S
</tr>
</tbody>
</table>
<p>There are <strong>293</strong> script scenarios with metadata in the site | Generated: 13 Oct 2024 08:34:08</p>
<p>There are <strong>295</strong> script scenarios with metadata in the site | Generated: 23 Oct 2024 04:52:44</p>
</article>
</div>
</div>
Expand Down
Loading

0 comments on commit 22b495b

Please sign in to comment.