Retrieve The List Of Apps Installed In The Specified Team Using Microsoft Teams Graph API In PowerShell

Graph API can be used to automate Microsoft Teams lifecycle such as creating teams, channels, adding members etc.
 
Refer to this link to know the list of Graph APIs available for Microsoft Teams.
 
You will see how to retrieve the list of apps installed in the specified team by calling Graph API in PowerShell.
 
List apps in team.
 

Microsoft Graph Explorer

 
HTTP - GET https://graph.microsoft.com/v1.0/teams/{id}/installedApps?$expand=teamsAppDefinition
 
Retrieve The List Of Apps Installed In The Specified Team Using Microsoft Teams Graph API In PowerShell
 
In this article, you will see how to perform the following tasks:
  • Register an Application in Azure - Register an app in Azure AD and add the required permissions to access the Graph API
  • Create and execute the PowerShell script

Register an application in Azure

 
Register an application in Azure AD to access the Teams Graph API.
  1. Navigate to Azure portal.
  2. Search for App Registrations. Click App Registrations as show below.

    Retrieve The List Of Apps Installed In The Specified Team Using Microsoft Teams Graph API In PowerShell
  1. Click New Registration.

    Retrieve The List Of Apps Installed In The Specified Team Using Microsoft Teams Graph API In PowerShell
  1. Enter the Name and click Register.

    Retrieve The List Of Apps Installed In The Specified Team Using Microsoft Teams Graph API In PowerShell
  1. App registered successfully. In the left navigation, click API Permissions.

    Retrieve The List Of Apps Installed In The Specified Team Using Microsoft Teams Graph API In PowerShell
  1. Click Add a permission.

    Retrieve The List Of Apps Installed In The Specified Team Using Microsoft Teams Graph API In PowerShell
  1. Select Microsoft Graph API as shown below.

    Retrieve The List Of Apps Installed In The Specified Team Using Microsoft Teams Graph API In PowerShell
  1. Click Application Permissions.

    Retrieve The List Of Apps Installed In The Specified Team Using Microsoft Teams Graph API In PowerShell
  1. Select Read.All permission and click Add permissions.

    Retrieve The List Of Apps Installed In The Specified Team Using Microsoft Teams Graph API In PowerShell
  1. Click Grant admin consent.

    Retrieve The List Of Apps Installed In The Specified Team Using Microsoft Teams Graph API In PowerShell

    Retrieve The List Of Apps Installed In The Specified Team Using Microsoft Teams Graph API In PowerShell
  1. In the left navigation, click Overview. Copy the Application (client) ID value. This value will be used in PowerShell for authentication.

    Retrieve The List Of Apps Installed In The Specified Team Using Microsoft Teams Graph API In PowerShell
  1. In the left navigation, click certificates & secrets. Click New client secret.

    Retrieve The List Of Apps Installed In The Specified Team Using Microsoft Teams Graph API In PowerShell
  1. Enter the description and click Add.

    Retrieve The List Of Apps Installed In The Specified Team Using Microsoft Teams Graph API In PowerShell
  1. Copy the secret value which will be used in PowerShell for authentication.

    Retrieve The List Of Apps Installed In The Specified Team Using Microsoft Teams Graph API In PowerShell

Create and execute the PowerShell script

  1. Open Notepad and paste the following code. Save the file as ps1.
    1. # Input Parameters  
    2. $clientId = "c714f180-c8cc-4f70-b720-409c798274a9"  
    3. $clientSecret = "fXzmWCUDmeXXqQ@D3b4xxd6GzrAY5[@="  
    4. $tenantName = "c986.onmicrosoft.com"  
    5. $resource = "https://graph.microsoft.com/"  
    6. $URL = "https://graph.microsoft.com/v1.0/teams/daba3aa7-6622-4f75-8e27-a9587c6642dc/installedApps/?`$expand=teamsAppDefinition"  
    7.   
    8.   
    9. $tokenBody = @{  
    10.     Grant_Type    = "client_credentials"  
    11.     Scope         = "https://graph.microsoft.com/.default"  
    12.     Client_Id     = $clientId  
    13.     Client_Secret = $clientSecret  
    14. }   
    15.   
    16. $tokenResponse = Invoke-RestMethod -Uri "https://login.microsoftonline.com/$TenantName/oauth2/v2.0/token" -Method POST -Body $tokenBody  
    17. $result=Invoke-RestMethod -Headers @{Authorization = "Bearer $($tokenResponse.access_token)"} -Uri $URL -Method Get  
    18. ($result| Select-Object value).Value.teamsAppDefinition  
  2. Open PowerShell window. Navigate to the folder path where the script file is saved.
  3. Execute the following script.

    .\ListAllApps.ps1

    Retrieve The List Of Apps Installed In The Specified Team Using Microsoft Teams Graph API In PowerShell

Summary

 
Thus, in this article, you saw how to retrieve the list of apps installed in the specified team using Microsoft Teams Graph API in PowerShell.


Similar Articles