Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get Azure AD Tenant Configuration
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
You can’t perform that action at this time.