【问题标题】:Get the tenant id of an registred app in azure AD using microsoft graph powershellGet the tenant id of an registred app in azure AD using microsoft graph powershell
【发布时间】:2022-12-01 15:30:19
【问题描述】:

I know how to get the tenant id of Azure AD. But i have registred an APP in Azure AD using microsoft graph powershell and i want to obtain tenant id of this registred app using microsoft graph powershell. I tried to get it using the variable i used to create the app registration:

$APP = New-MgApplication   -displayName $AppName `
                           -RequiredResourceAccess @{ ResourceAppId = $GraphResourceId; ResourceAccess = @($resourceAccess) } `
                           -SignInAudience $SignInAudience `
                           -PublicClient @{ RedirectUris = $URL }

If i use the variable $App and try to get a property called tenantid, there is nth called like this. $App | Select * did not show any tenantid aswell.

Anyone know how to read the tenantid of this registred azure app using microsoft graph powershell?

【问题讨论】:

    标签: azure-active-directory microsoft-graph-sdks


    【解决方案1】:

    You can get the tenant id, by following below commands , ref doc - https://learn.microsoft.com/en-us/azure/active-directory/fundamentals/active-directory-how-to-find-tenant#find-tenant-id-with-powershell

    Connect-AzAccount

    Get-AzTenant

    To list all To the tenants for your account, you can use: GET https://management.azure.com/tenants?api-version=2020-01-01 ref doc - https://docs.microsoft.com/en-us/rest/api/resources/tenants/list

    If you want to see the tenant ID associated with an app registration, you can do so through the portal under Azure Active Directory > App Registrations > the app registration > Overview. I don't believe it's possible to get this data via Powershell since Powershell requires both Tenant ID and Application ID to query the application information.

    See the doc more info - https://learn.microsoft.com/en-us/partner-center/find-ids-and-domain-names

    Hope this helps

    Thanks

    【讨论】:

      【解决方案2】:

      Graph API doesn't provide any information about tenant for registered application, so you cannot get tenant id directly.

      The registered application is created under the same tenant that the user or application is signed in to.

      You can read organization data

      Import-Module Microsoft.Graph.Identity.DirectoryManagement
      
      $org = Get-MgOrganization
      

      $org.id is the tenant ID.

      Documentation:

      Organization

      【讨论】:

        猜你喜欢
        • 2013-09-30
        • 2022-12-01
        • 2022-12-28
        • 1970-01-01
        • 2022-07-29
        • 2018-03-02
        • 2022-12-02
        • 2020-06-27
        • 1970-01-01
        相关资源
        最近更新 更多