Skip to content

Commit e333ec7

Browse files
msewawerupeombwa
andauthored
Added examples to the cmdlets (#791)
* Added examples to the cmdlets * Added more examples to cmdlets * Added more examples * Added examples to cmdlets * Added more examples Co-authored-by: Peter Ombwa <peter.ombwa@microsoft.com>
1 parent b7d85f2 commit e333ec7

31 files changed

Lines changed: 323 additions & 389 deletions
Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
### Example 1: {{ Add title here }}
2-
```powershell
3-
PS C:\> {{ Add code here }}
4-
5-
{{ Add output here }}
6-
```
1+
### Example 1: Get appRoleAssignments granted to a group
72

8-
{{ Add description here }}
9-
10-
### Example 2: {{ Add title here }}
113
```powershell
12-
PS C:\> {{ Add code here }}
4+
Get-MgGroupAppRoleAssignment -GroupId '2692d278-8323-4094-b286-e0ffce5e54a5' |
5+
Format-List
136
14-
{{ Add output here }}
7+
AppRoleId : 00000000-0000-0000-0000-000000000000
8+
CreatedDateTime : 7/29/2021 10:08:49 AM
9+
DeletedDateTime :
10+
Id : eNKSJiODlECyhuD_zl5UpexaKrcAYuZEhjCKxfNmzDM
11+
PrincipalDisplayName : Marketing
12+
PrincipalId : 2692d278-8323-4094-b286-e0ffce5e54a5
13+
PrincipalType : Group
14+
ResourceDisplayName : Common Data Service
15+
ResourceId : 93af1c70-e87f-45df-8780-8af2d7afd05e
16+
AdditionalProperties : {}
1517
```
1618

17-
{{ Add description here }}
18-
19+
This example get all app role assignments granted to the specified group.
Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,33 @@
1-
### Example 1: {{ Add title here }}
2-
```powershell
3-
PS C:\> {{ Add code here }}
4-
5-
{{ Add output here }}
6-
```
1+
### Example 1: Get all application role assignments for a service principal
72

8-
{{ Add description here }}
9-
10-
### Example 2: {{ Add title here }}
113
```powershell
12-
PS C:\> {{ Add code here }}
4+
Get-MgServicePrincipalAppRoleAssignment -ServicePrincipalId '0bdb123d-b8a7-4cc9-8cc2-bd17bad06f61' | Format-List
135
14-
{{ Add output here }}
15-
```
6+
AppRoleId : 00000000-0000-0000-0000-000000000000
7+
CreatedDateTime : 8/31/2021 2:01:28 PM
8+
DeletedDateTime :
9+
Id : PRLbC6e4yUyMwr0XutBvYfZHkKGzlbxDr2I-QJWN9rs
10+
PrincipalDisplayName : Example App
11+
PrincipalId : 0bdb123d-b8a7-4cc9-8cc2-bd17bad06f61
12+
PrincipalType : ServicePrincipal
13+
ResourceDisplayName : Office 365 Management APIs
14+
ResourceId : 557aedfc-007c-4904-918a-7e6fed2e7403
15+
AdditionalProperties : {[@odata.id, https://graph.microsoft.com/v2/fb625e04-52aa-42da-b10d-14f1195d665f/directoryObjects/$/Microsof
16+
t.DirectoryServices.ServicePrincipal('0bdb123d-b8a7-4cc9-8cc2-bd17bad06f61')/appRoleAssignments/PRLbC6e4yUyM
17+
wr0XutBvYfZHkKGzlbxDr2I-QJWN9rs]}
1618
17-
{{ Add description here }}
19+
AppRoleId : 00000000-0000-0000-0000-000000000000
20+
CreatedDateTime : 8/31/2021 1:59:44 PM
21+
DeletedDateTime :
22+
Id : PRLbC6e4yUyMwr0XutBvYZsr7FiAW3pIqP4F9944yBc
23+
PrincipalDisplayName : Example App
24+
PrincipalId : 0bdb123d-b8a7-4cc9-8cc2-bd17bad06f61
25+
PrincipalType : ServicePrincipal
26+
ResourceDisplayName : Office 365 SharePoint Online
27+
ResourceId : 1c48f923-4fbb-4d37-b772-4d577eefec9e
28+
AdditionalProperties : {[@odata.id, https://graph.microsoft.com/v2/fb625e04-52aa-42da-b10d-14f1195d665f/directoryObjects/$/Microsof
29+
t.DirectoryServices.ServicePrincipal('0bdb123d-b8a7-4cc9-8cc2-bd17bad06f61')/appRoleAssignments/PRLbC6e4yUyM
30+
wr0XutBvYZsr7FiAW3pIqP4F9944yBc]}
31+
```
1832

33+
This example gets the application role assignments that have been granted to the specified service principal.
Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
1-
### Example 1: {{ Add title here }}
2-
```powershell
3-
PS C:\> {{ Add code here }}
4-
5-
{{ Add output here }}
6-
```
1+
### Example 1: List the owners of a service principal
72

8-
{{ Add description here }}
9-
10-
### Example 2: {{ Add title here }}
113
```powershell
12-
PS C:\> {{ Add code here }}
4+
Get-MgServicePrincipalOwner -ServicePrincipalId '1c48f923-4fbb-4d37-b772-4d577eefec9e'
135
14-
{{ Add output here }}
6+
Id DeletedDateTime
7+
-- ---------------
8+
8a7c50d3-fcbd-4727-a889-8ab232dfea01
159
```
1610

17-
{{ Add description here }}
18-
11+
This command lists the owners of the specified service principal.
Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,36 @@
1-
### Example 1: {{ Add title here }}
1+
### Example 1: Assign an app role to a group
2+
23
```powershell
3-
PS C:\> {{ Add code here }}
4+
$appRoleAssignment = @{
5+
"principalId"= "f07a8d78-f18c-4c02-b339-9ebace025122"
6+
"resourceId"= "1c48f923-4fbb-4d37-b772-4d577eefec9e"
7+
"appRoleId"= "00000000-0000-0000-0000-000000000000"
8+
}
9+
10+
New-MgGroupAppRoleAssignment -GroupId 'f07a8d78-f18c-4c02-b339-9ebace025122' -BodyParameter $appRoleAssignment |
11+
Format-List
412
5-
{{ Add output here }}
13+
AppRoleId : 00000000-0000-0000-0000-000000000000
14+
CreatedDateTime : 8/19/2021 11:25:25 AM
15+
DeletedDateTime :
16+
Id : eI168IzxAkyzOZ66zgJRIqVVeeA1CVFKmaBn-MGn0Bw
17+
PrincipalDisplayName : All Employees
18+
PrincipalId : f07a8d78-f18c-4c02-b339-9ebace025122
19+
PrincipalType : Group
20+
ResourceDisplayName : Office 365 SharePoint Online
21+
ResourceId : 1c48f923-4fbb-4d37-b772-4d577eefec9e
22+
AdditionalProperties : {[@odata.context, https://graph.microsoft.com/v1.0/$metadata#groups('f07a8d78-f18c-4c02-b339-9ebace025122')/appRoleAssignments/$entity], [@odata.id, https://graph.microsoft.com/v2/fb625e04-52aa-42da-
23+
b10d-14f1195d665f/directoryObjects/$/Microsoft.DirectoryServices.Group('f07a8d78-f18c-4c02-b339-9ebace025122')/appRoleAssignments/eI168IzxAkyzOZ66zgJRIqVVeeA1CVFKmaBn-MGn0Bw]}
624
```
725

8-
{{ Add description here }}
26+
In this example, the first command defines the `$appRoleAssignment` variable that defines the following:
927

10-
### Example 2: {{ Add title here }}
11-
```powershell
12-
PS C:\> {{ Add code here }}
28+
-`principalId`: The id of the group to which you are assigning the app role.
1329

14-
{{ Add output here }}
15-
```
30+
-`resourceId`: The id of the resource servicePrincipal which has defined the app role.
31+
32+
-`appRoleId`: The id of the appRole (defined on the resource service principal) to assign to the group.
1633

17-
{{ Add description here }}
34+
Learn more about the [AppRoleAssignment resource](/graph/api/resources/approleassignment?view=graph-rest-1.0).
1835

36+
The second command adds the role to the specified group.
Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,37 @@
11
### Example 1: {{ Add title here }}
2+
23
```powershell
3-
PS C:\> {{ Add code here }}
4+
$appRoleAssignment = @{
5+
"principalId"= "0bdb123d-b8a7-4cc9-8cc2-bd17bad06f61"
6+
"resourceId"= "557aedfc-007c-4904-918a-7e6fed2e7403"
7+
"appRoleId"= "00000000-0000-0000-0000-000000000000"
8+
}
9+
10+
New-MgServicePrincipalAppRoleAssignment -ServicePrincipalId 0bdb123d-b8a7-4cc9-8cc2-bd17bad06f61 -BodyParameter $appRoleAssignment | Format-List
411
5-
{{ Add output here }}
12+
AppRoleId : 00000000-0000-0000-0000-000000000000
13+
CreatedDateTime : 8/31/2021 2:01:28 PM
14+
DeletedDateTime :
15+
Id : PRLbC6e4yUyMwr0XutBvYfZHkKGzlbxDr2I-QJWN9rs
16+
PrincipalDisplayName : Example App
17+
PrincipalId : 0bdb123d-b8a7-4cc9-8cc2-bd17bad06f61
18+
PrincipalType : ServicePrincipal
19+
ResourceDisplayName : Office 365 Management APIs
20+
ResourceId : 557aedfc-007c-4904-918a-7e6fed2e7403
21+
AdditionalProperties : {[@odata.context, https://graph.microsoft.com/v1.0/$metadata#servicePrincipals('0bdb123d-b8a7-4cc9-8cc2-bd17
22+
bad06f61')/appRoleAssignments/$entity], [@odata.id, https://graph.microsoft.com/v2/fb625e04-52aa-42da-b10d-1
23+
4f1195d665f/directoryObjects/$/Microsoft.DirectoryServices.ServicePrincipal('0bdb123d-b8a7-4cc9-8cc2-bd17bad
24+
06f61')/appRoleAssignments/PRLbC6e4yUyMwr0XutBvYfZHkKGzlbxDr2I-QJWN9rs]}
625
```
726

8-
{{ Add description here }}
27+
In this example, the first command defines the `$appRoleAssignment` variable that defines the following:
928

10-
### Example 2: {{ Add title here }}
11-
```powershell
12-
PS C:\> {{ Add code here }}
29+
-`principalId`: The id of the client service principal to which you are assigning the app role.
1330

14-
{{ Add output here }}
15-
```
31+
-`resourceId`: The id of the resource `servicePrincipal` (the API) which has defined the app role (the application permission).
32+
33+
-`appRoleId`: The id of the appRole (defined on the resource service principal) to assign to the client service principal.
1634

17-
{{ Add description here }}
35+
Learn more about the [AppRoleAssignment resource](/graph/api/resources/approleassignment?view=graph-rest-1.0).
1836

37+
The second command adds the role to the specified service principal.
Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
1-
### Example 1: {{ Add title here }}
2-
```powershell
3-
PS C:\> {{ Add code here }}
4-
5-
{{ Add output here }}
6-
```
1+
### Example 1: Add an owner for a service principal
72

8-
{{ Add description here }}
9-
10-
### Example 2: {{ Add title here }}
113
```powershell
12-
PS C:\> {{ Add code here }}
4+
$newOwner = @{
5+
"@odata.id"= "https://graph.microsoft.com/v1.0/directoryObjects/8a7c50d3-fcbd-4727-a889-8ab232dfea01"
6+
}
137
14-
{{ Add output here }}
8+
New-MgServicePrincipalOwnerByRef -ServicePrincipalId '1c48f923-4fbb-4d37-b772-4d577eefec9e' -BodyParameter $newOwner
159
```
1610

17-
{{ Add description here }}
18-
11+
In this example, the first command defines the value for the `$newOwner` variable in a hashtable. The second command adds the new owner to the specified service principal.
Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
1-
### Example 1: {{ Add title here }}
2-
```powershell
3-
PS C:\> {{ Add code here }}
4-
5-
{{ Add output here }}
6-
```
1+
### Example 1: Delete an application
72

8-
{{ Add description here }}
9-
10-
### Example 2: {{ Add title here }}
113
```powershell
12-
PS C:\> {{ Add code here }}
13-
14-
{{ Add output here }}
4+
Remove-MgApplication -ApplicationId '1bc44759-ef10-46de-b199-40c077768fff'
155
```
166

17-
{{ Add description here }}
18-
7+
This example deletes the specified application.
Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
1-
### Example 1: {{ Add title here }}
2-
```powershell
3-
PS C:\> {{ Add code here }}
4-
5-
{{ Add output here }}
6-
```
1+
### Example 1: Remove the application role assignment for a service principal
72

8-
{{ Add description here }}
9-
10-
### Example 2: {{ Add title here }}
113
```powershell
12-
PS C:\> {{ Add code here }}
13-
14-
{{ Add output here }}
4+
Remove-MgServicePrincipalAppRoleAssignment -AppRoleAssignmentId 'PRLbC6e4yUyMwr0XutBvYZsr7FiAW3pIqP4F9944yBc' -ServicePrincipalId '0bdb123d-b8a7-4cc9-8cc2-bd17bad06f61'
155
```
166

17-
{{ Add description here }}
18-
7+
This example removed the assignment of the specified service principal to the specified application role id.
Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
### Example 1: {{ Add title here }}
2-
```powershell
3-
PS C:\> {{ Add code here }}
4-
5-
{{ Add output here }}
6-
```
1+
### Example 1: Get appRoleAssignments granted to a group
72

8-
{{ Add description here }}
9-
10-
### Example 2: {{ Add title here }}
113
```powershell
12-
PS C:\> {{ Add code here }}
4+
Get-MgGroupAppRoleAssignment -GroupId '2692d278-8323-4094-b286-e0ffce5e54a5' |
5+
Format-List
136
14-
{{ Add output here }}
7+
AppRoleId : 00000000-0000-0000-0000-000000000000
8+
CreatedDateTime : 7/29/2021 10:08:49 AM
9+
DeletedDateTime :
10+
Id : eNKSJiODlECyhuD_zl5UpexaKrcAYuZEhjCKxfNmzDM
11+
PrincipalDisplayName : Marketing
12+
PrincipalId : 2692d278-8323-4094-b286-e0ffce5e54a5
13+
PrincipalType : Group
14+
ResourceDisplayName : Common Data Service
15+
ResourceId : 93af1c70-e87f-45df-8780-8af2d7afd05e
16+
AdditionalProperties : {}
1517
```
1618

17-
{{ Add description here }}
18-
19+
This example get all app role assignments granted to the specified group.
Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,33 @@
1-
### Example 1: {{ Add title here }}
2-
```powershell
3-
PS C:\> {{ Add code here }}
4-
5-
{{ Add output here }}
6-
```
1+
### Example 1: Get all application role assignments for a service principal
72

8-
{{ Add description here }}
9-
10-
### Example 2: {{ Add title here }}
113
```powershell
12-
PS C:\> {{ Add code here }}
4+
Get-MgServicePrincipalAppRoleAssignment -ServicePrincipalId '0bdb123d-b8a7-4cc9-8cc2-bd17bad06f61' | Format-List
135
14-
{{ Add output here }}
15-
```
6+
AppRoleId : 00000000-0000-0000-0000-000000000000
7+
CreatedDateTime : 8/31/2021 2:01:28 PM
8+
DeletedDateTime :
9+
Id : PRLbC6e4yUyMwr0XutBvYfZHkKGzlbxDr2I-QJWN9rs
10+
PrincipalDisplayName : Example App
11+
PrincipalId : 0bdb123d-b8a7-4cc9-8cc2-bd17bad06f61
12+
PrincipalType : ServicePrincipal
13+
ResourceDisplayName : Office 365 Management APIs
14+
ResourceId : 557aedfc-007c-4904-918a-7e6fed2e7403
15+
AdditionalProperties : {[@odata.id, https://graph.microsoft.com/v2/fb625e04-52aa-42da-b10d-14f1195d665f/directoryObjects/$/Microsof
16+
t.DirectoryServices.ServicePrincipal('0bdb123d-b8a7-4cc9-8cc2-bd17bad06f61')/appRoleAssignments/PRLbC6e4yUyM
17+
wr0XutBvYfZHkKGzlbxDr2I-QJWN9rs]}
1618
17-
{{ Add description here }}
19+
AppRoleId : 00000000-0000-0000-0000-000000000000
20+
CreatedDateTime : 8/31/2021 1:59:44 PM
21+
DeletedDateTime :
22+
Id : PRLbC6e4yUyMwr0XutBvYZsr7FiAW3pIqP4F9944yBc
23+
PrincipalDisplayName : Example App
24+
PrincipalId : 0bdb123d-b8a7-4cc9-8cc2-bd17bad06f61
25+
PrincipalType : ServicePrincipal
26+
ResourceDisplayName : Office 365 SharePoint Online
27+
ResourceId : 1c48f923-4fbb-4d37-b772-4d577eefec9e
28+
AdditionalProperties : {[@odata.id, https://graph.microsoft.com/v2/fb625e04-52aa-42da-b10d-14f1195d665f/directoryObjects/$/Microsof
29+
t.DirectoryServices.ServicePrincipal('0bdb123d-b8a7-4cc9-8cc2-bd17bad06f61')/appRoleAssignments/PRLbC6e4yUyM
30+
wr0XutBvYZsr7FiAW3pIqP4F9944yBc]}
31+
```
1832

33+
This example gets the application role assignments that have been granted to the specified service principal.

0 commit comments

Comments
 (0)