Skip to content

Instantly share code, notes, and snippets.

@tyconsulting
Created January 7, 2018 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tyconsulting/7c313dc98947f0e413cf69b0b2321013 to your computer and use it in GitHub Desktop.
Save tyconsulting/7c313dc98947f0e413cf69b0b2321013 to your computer and use it in GitHub Desktop.
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