The Invoke-MgGraphRequest
cmdlet is a versatile tool in Microsoft Graph PowerShell that allows you to make custom API requests. This article explains how to use it to retrieve all apps installed in a Microsoft Team. Though Get-MgTeamInstalledApp is available, Invoke-MgGraphRequest
provides additional flexibility for custom API calls. Let's explore the syntax, examples, and tips for using this cmdlet effectively.
Invoke-MgGraphRequest -Method GET -Uri "https://graph.microsoft.com/v1.0/teams/{team-id}/installedApps"
Replace {team-id}
with the actual ID of the Microsoft Team from which you want to retrieve installed apps.
This command retrieves all apps installed in the team with the specified ID.
$teamId = "6903fa93-605b-43ef-920e-77c4729f8258"
Invoke-MgGraphRequest -Method GET -Uri "https://graph.microsoft.com/v1.0/teams/$teamId/installedApps"
Connect-MgGraph
before making API calls.TeamsApp.Read.All
or TeamsAppInstallation.ReadForUser.All
) are granted to your app or account.@odata.nextLink
property to retrieve additional pages.Cause: Insufficient permissions to list the installed apps in the team.
Solution: Ensure you have the correct permissions. You may need to grant the appropriate permissions in Azure AD.
Cause: The team ID is incorrect or malformed.
Solution: Verify the team ID using Get-MgTeam
or Get-MgGroup
to retrieve the correct ID.
Cause: Microsoft Graph's throttling limit has been exceeded.
Solution: Implement retry logic by waiting for a specified period before retrying. Use the Retry-After
header to determine the recommended wait time.
Administrators can use this cmdlet to monitor installed apps and ensure compliance with internal policies by comparing installed apps against an approved list.
$approvedApps = @("com.microsoft.todo", "com.microsoft.powerbi")
$installedApps = Invoke-MgGraphRequest -Method GET -Uri "https://graph.microsoft.com/v1.0/teams/$teamId/installedApps"
$nonApprovedApps = $installedApps.value | Where-Object { $_.'teamsApp@odata.bind' -notin $approvedApps }
Use Invoke-MgGraphRequest
to gather data on app installations across teams, then generate reports to analyze app usage trends.
$teamIds = @("teamId1", "teamId2", "teamId3")
foreach ($teamId in $teamIds) {
$installedApps = Invoke-MgGraphRequest -Method GET -Uri "https://graph.microsoft.com/v1.0/teams/$teamId/installedApps"
$appReport += $installedApps.value | Select-Object @{n='TeamId'; e={$teamId}}, 'teamsApp@odata.bind'
}
$appReport | Export-Csv -Path "AppUsageReport.csv" -NoTypeInformation
The Invoke-MgGraphRequest
cmdlet is a powerful tool for making custom API requests not covered by specific Graph PowerShell cmdlets. By using it to list apps installed in Microsoft Teams, administrators can automate app monitoring, ensure compliance, and generate useful reports. Its flexibility makes it invaluable for working with the full spectrum of Microsoft Graph APIs, allowing for advanced customization in managing Teams environments.
© m365corner.com. All Rights Reserved. Design by HTML Codex