-
-
Save tyconsulting/7c313dc98947f0e413cf69b0b2321013 to your computer and use it in GitHub Desktop.
Get Azure AD Tenant Configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Get-AADTenantConfiguration | |
{ | |
[CmdletBinding()] | |
[OutputType([string])] | |
PARAM ( | |
[Parameter(ParameterSetName = 'ByTenantId', Position=0,Mandatory=$true)] | |
[ValidateScript({ | |
try | |
{ | |
[System.Guid]::Parse($_) | Out-Null | |
$true | |
} | |
catch | |
{ | |
$false | |
} | |
})] | |
[Alias('tID')] | |
[String]$TenantID, | |
[Parameter(ParameterSetName = 'ByTenantName', Position=1,Mandatory=$true)][Alias('cred')] | |
[ValidateNotNullOrEmpty()] | |
[String] | |
$TenantName | |
) | |
if ($PScmdlet.ParameterSetName -eq 'ByTenantId') | |
{ | |
$URI = "https://login.windows.net/$TenantId/.well-known/openid-configuration" | |
} else { | |
$URI = "https://login.windows.net/$TenantName/.well-known/openid-configuration" | |
} | |
$Response = Invoke-WebRequest -UseBasicParsing -Uri $URI -Method Get | |
$json = ConvertFrom-Json -InputObject $Response.Content | |
$json | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment