Skip to content

Commit a859f24

Browse files
Merge pull request #205346 from omondiatieno/add-msgraph-cmdlets
add microsoft graph cmdlets
2 parents b8b5485 + 84c30d4 commit a859f24

File tree

2 files changed

+94
-9
lines changed

2 files changed

+94
-9
lines changed

articles/active-directory/manage-apps/manage-application-permissions.md

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ms.topic: how-to
1111
ms.date: 10/23/2021
1212
ms.author: jawoods
1313
ms.reviewer: phsignor
14-
14+
zone_pivot_groups: enterprise-apps-minus-graph
1515
ms.collection: M365-identity-device-management
1616

1717
#customer intent: As an admin, I want to review permissions granted to applications so that I can restrict suspicious or over privileged applications.
@@ -32,10 +32,11 @@ To review permissions granted to applications, you need:
3232
- One of the following roles: Global Administrator, Cloud Application Administrator, Application Administrator.
3333
- A Service principal owner who isn't an administrator is able to invalidate refresh tokens.
3434

35+
## Review application permissions
3536

36-
You can access the Azure AD portal to get contextual PowerShell scripts to perform the actions.
37+
:::zone pivot="portal"
3738

38-
## Review application permissions
39+
You can access the Azure AD portal to get contextual PowerShell scripts to perform the actions.
3940

4041
To review application permissions:
4142

@@ -48,9 +49,11 @@ To review application permissions:
4849

4950
Each option generates PowerShell scripts that enable you to control user access to the application and to review permissions granted to the application. For information about how to control user access to an application, see [How to remove a user's access to an application](methods-for-removing-user-access.md)
5051

51-
## Revoke permissions using PowerShell commands
52+
:::zone-end
5253

53-
Using the following PowerShell script revokes all permissions granted to this application.
54+
:::zone pivot="aad-powershell"
55+
56+
Using the following Azure AD PowerShell script revokes all permissions granted to an application.
5457

5558
```powershell
5659
Connect-AzureAD
@@ -75,9 +78,6 @@ $spApplicationPermissions | ForEach-Object {
7578
}
7679
```
7780

78-
> [!NOTE]
79-
> Revoking the current granted permission won't stop users from re-consenting to the application. If you want to block users from consenting, read [Configure how users consent to applications](configure-user-consent.md).
80-
8181
## Invalidate the refresh tokens
8282

8383
```powershell
@@ -94,6 +94,51 @@ $assignments | ForEach-Object {
9494
Revoke-AzureADUserAllRefreshToken -ObjectId $_.PrincipalId
9595
}
9696
```
97+
:::zone-end
98+
:::zone pivot="ms-powershell"
99+
100+
Using the following Microsoft Graph PowerShell script revokes all permissions granted to an application.
101+
102+
```powershell
103+
Connect-MgGraph
104+
105+
# Get Service Principal using objectId
106+
$sp = Get-MgServicePrincipal -ServicePrincipalID "$ServicePrincipalID"
107+
108+
Example: Get-MgServicePrincipal -ServicePrincipalId '22c1770d-30df-49e7-a763-f39d2ef9b369'
109+
110+
# Get all application permissions for the service principal
111+
$spOAuth2PermissionsGrants= Get-MgOauth2PermissionGrant -All| Where-Object { $_.clientId -eq $sp.Id }
112+
113+
# Remove all delegated permissions
114+
$spOauth2PermissionsGrants |ForEach-Object {
115+
Remove-MgOauth2PermissionGrant -OAuth2PermissionGrantId $_.Id
116+
}
117+
```
118+
119+
## Invalidate the refresh tokens
120+
121+
```powershell
122+
Connect-MgGraph
123+
124+
# Get Service Principal using objectId
125+
$sp = Get-MgServicePrincipal -ServicePrincipalID "$ServicePrincipalID"
126+
127+
Example: Get-MgServicePrincipal -ServicePrincipalId '22c1770d-30df-49e7-a763-f39d2ef9b369'
128+
129+
# Get Azure AD App role assignments using objectID of the Service Principal
130+
$spApplicationPermissions = Get-MgServicePrincipalAppRoleAssignedTo -ServicePrincipalID $sp.Id -All | Where-Object { $_.PrincipalType -eq "ServicePrincipal" }
131+
132+
# Revoke refresh token for all users assigned to the application
133+
$spApplicationPermissions | ForEach-Object {
134+
Remove-MgServicePrincipalAppRoleAssignment -ServicePrincipalId $_.PrincipalId -AppRoleAssignmentId $_.Id
135+
}
136+
```
137+
138+
:::zone-end
139+
140+
> [!NOTE]
141+
> Revoking the current granted permission won't stop users from re-consenting to the application. If you want to block users from consenting, read [Configure how users consent to applications](configure-user-consent.md).
97142
98143
## Next steps
99144

articles/zone-pivot-groups.yml

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1611,7 +1611,12 @@ groups:
16111611
title: Basic/Standard tier
16121612
- id: sc-enterprise-tier
16131613
title: Enterprise tier
1614-
# Owner: jomondi
1614+
########### BEGIN APPLICATION MANAGEMENT
1615+
# Service: Active Directory (active-directory)
1616+
# Sub-service: APPLICATION MANAGEMENT(manage-apps)
1617+
# Referenced by: /articles/active-directory/manage-apps/*
1618+
# Owner(s): jomondi, celested
1619+
## Home realm discovery ##
16151620
- id: home-realm-discovery
16161621
title: hrd-policy
16171622
prompt: Choose an option
@@ -1620,6 +1625,41 @@ groups:
16201625
title: PowerShell
16211626
- id: graph-hrd
16221627
title: Graph
1628+
## Generic how-to doc template
1629+
- id: enterprise-apps
1630+
title: Manage Enterpise apps
1631+
prompt: Choose an option
1632+
pivots:
1633+
- id: portal
1634+
title: Azure Portal
1635+
- id: aad-PowerShell
1636+
title: Azure AD PowerShell
1637+
- id: ms-PowerShell
1638+
title: Microsoft Graph PowerShell
1639+
- id: ms-graph
1640+
title: Microsoft Graph
1641+
## Generic how-to doc template without graph
1642+
- id: enterprise-apps-minus-graph
1643+
title: Manage Enterpise apps
1644+
prompt: Choose an option
1645+
pivots:
1646+
- id: portal
1647+
title: Azure Portal
1648+
- id: aad-powershell
1649+
title: Azure AD PowerShell
1650+
- id: ms-powershell
1651+
title: Microsoft Graph PowerShell
1652+
## Create service principal with appId
1653+
- id: enterprise-apps-cli
1654+
title: Enterpise apps
1655+
prompt: Choose an option
1656+
pivots:
1657+
- id: msgraph-powershell
1658+
title: Microsoft graph PowerShell
1659+
- id: ms-graph
1660+
title: Microsoft Graph
1661+
- id: azure-cli
1662+
title: Azure CLI
16231663
# Owner: juliakm
16241664
- id: pipelines-version
16251665
title: Pipelines version

0 commit comments

Comments
 (0)