Skip to content

Commit b96ab85

Browse files
msewawerupeombwa
andauthored
Added examples to CA cmdlets (#1320)
* Added examples to CA cmdlets * Added more examples Co-authored-by: Peter Ombwa <[email protected]>
1 parent 5150945 commit b96ab85

16 files changed

+457
-176
lines changed
Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
1-
### Example 1: {{ Add title here }}
1+
### Example 1: Get a list of all named locations
2+
23
```powershell
3-
PS C:\> {{ Add code here }}
4+
Connect-MgGraph -Scopes 'Policy.Read.All'
5+
Get-MgIdentityConditionalAccessNamedLocation
46
5-
{{ Add output here }}
7+
Id CreatedDateTime DisplayName ModifiedDateTime
8+
-- --------------- ----------- ----------------
9+
1b43b630-dbef-4cb7-afe5-fa4e113ea6b2 4/21/2022 10:28:22 AM KOs 6/13/2022 8:23:06 AM
10+
1f0fd623-bf8f-4003-9627-32a68c3cdcc1 6/13/2022 8:27:35 AM Updated named location 6/13/2022 8:54:24 AM
11+
0824dbaf-6277-4db0-8112-b29fd356f2c4 6/13/2022 8:41:38 AM Untrusted IP named location 6/13/2022 8:41:38 AM
612
```
713

8-
{{ Add description here }}
14+
This example lists all existing named location rules.
15+
16+
### Example 2: Get a named location by Id
917

10-
### Example 2: {{ Add title here }}
1118
```powershell
12-
PS C:\> {{ Add code here }}
19+
Connect-MgGraph -Scopes 'Policy.Read.All'
20+
Get-MgIdentityConditionalAccessNamedLocation -NamedLocationId '1f0fd623-bf8f-4003-9627-32a68c3cdcc1'
1321
14-
{{ Add output here }}
22+
Id CreatedDateTime DisplayName ModifiedDateTime
23+
-- --------------- ----------- ----------------
24+
1f0fd623-bf8f-4003-9627-32a68c3cdcc1 6/13/2022 8:27:35 AM Updated named location 6/13/2022 8:54:24 AM
1525
```
1626

17-
{{ Add description here }}
18-
27+
This example gets the named location rule by Id.
Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,51 @@
1-
### Example 1: {{ Add title here }}
1+
### Example 1: Get a list of all conditional access policies in Azure AD.
2+
23
```powershell
3-
PS C:\> {{ Add code here }}
4+
Connect-MgGraph -Scopes 'Policy.Read.All'
5+
Get-MgIdentityConditionalAccessPolicy |Format-List
6+
7+
Conditions : Microsoft.Graph.PowerShell.Models.MicrosoftGraphConditionalAccessConditionSet
8+
CreatedDateTime : 1/13/2022 6:35:35 AM
9+
Description :
10+
DisplayName : Exchange Online Requires Compliant Device
11+
GrantControls : Microsoft.Graph.PowerShell.Models.MicrosoftGraphConditionalAccessGrantControls
12+
Id : 5e7615b8-dbe4-4cc1-810c-26adb77a3518
13+
ModifiedDateTime : 7/29/2022 9:08:10 AM
14+
SessionControls : Microsoft.Graph.PowerShell.Models.MicrosoftGraphConditionalAccessSessionControls
15+
State : enabled
16+
AdditionalProperties : {}
417
5-
{{ Add output here }}
18+
Conditions : Microsoft.Graph.PowerShell.Models.MicrosoftGraphConditionalAccessConditionSet
19+
CreatedDateTime : 1/13/2022 6:35:39 AM
20+
Description :
21+
DisplayName : Office 365 App Control
22+
GrantControls : Microsoft.Graph.PowerShell.Models.MicrosoftGraphConditionalAccessGrantControls
23+
Id : 8783f4ea-215e-49f9-a4f6-cc21f6de45f6
24+
ModifiedDateTime : 7/29/2022 9:08:39 AM
25+
SessionControls : Microsoft.Graph.PowerShell.Models.MicrosoftGraphConditionalAccessSessionControls
26+
State : enabled
27+
AdditionalProperties : {}
628
```
729

8-
{{ Add description here }}
30+
This example retrieves all the conditional access policies in Azure AD.
31+
32+
### Example 2: Get a conditional access policy by Id
933

10-
### Example 2: {{ Add title here }}
1134
```powershell
12-
PS C:\> {{ Add code here }}
35+
Connect-MgGraph -Scopes 'Policy.Read.All'
36+
Get-MgIdentityConditionalAccessPolicy -ConditionalAccessPolicyId '5e7615b8-dbe4-4cc1-810c-26adb77a3518' |
37+
Format-List
1338
14-
{{ Add output here }}
39+
Conditions : Microsoft.Graph.PowerShell.Models.MicrosoftGraphConditionalAccessConditionSet
40+
CreatedDateTime : 1/13/2022 6:35:35 AM
41+
Description :
42+
DisplayName : Exchange Online Requires Compliant Device
43+
GrantControls : Microsoft.Graph.PowerShell.Models.MicrosoftGraphConditionalAccessGrantControls
44+
Id : 5e7615b8-dbe4-4cc1-810c-26adb77a3518
45+
ModifiedDateTime : 7/29/2022 9:08:10 AM
46+
SessionControls : Microsoft.Graph.PowerShell.Models.MicrosoftGraphConditionalAccessSessionControls
47+
State : enabled
48+
AdditionalProperties : {[@odata.context, https://graph.microsoft.com/v1.0/$metadata#identity/conditionalAccess/policies/$entity]}
1549
```
1650

17-
{{ Add description here }}
18-
51+
This command retrieves the conditional access by Id.
Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,53 @@
1-
### Example 1: {{ Add title here }}
1+
### Example 1: Create a country named location
2+
23
```powershell
3-
PS C:\> {{ Add code here }}
4+
Connect-MgGraph -Scopes 'Policy.ReadWrite.ConditionalAccess'
5+
6+
$params = @{
7+
"@odata.type" = "#microsoft.graph.countryNamedLocation"
8+
DisplayName = "Named location with unknown countries and regions"
9+
CountriesAndRegions = @(
10+
"US"
11+
"XK"
12+
)
13+
IncludeUnknownCountriesAndRegions = $true
14+
}
415
5-
{{ Add output here }}
16+
New-MgIdentityConditionalAccessNamedLocation -BodyParameter $params
17+
18+
Id CreatedDateTime DisplayName ModifiedDateTime
19+
-- --------------- ----------- ----------------
20+
1f0fd623-bf8f-4003-9627-32a68c3cdcc1 6/13/2022 8:27:35 AM Named location with unknown countries and regions 6/13/2022 8:27:35 AM
621
```
722

8-
{{ Add description here }}
23+
This example creates a country named location.
24+
25+
### Example 2: Create an ip named location
926

10-
### Example 2: {{ Add title here }}
1127
```powershell
12-
PS C:\> {{ Add code here }}
28+
Connect-MgGraph -Scopes 'Policy.ReadWrite.ConditionalAccess'
1329
14-
{{ Add output here }}
15-
```
30+
$params = @{
31+
"@odata.type" = "#microsoft.graph.ipNamedLocation"
32+
DisplayName = "Untrusted IP named location"
33+
IsTrusted = $false
34+
IpRanges = @(
35+
@{
36+
"@odata.type" = "#microsoft.graph.iPv4CidrRange"
37+
CidrAddress = "12.34.221.11/22"
38+
}
39+
@{
40+
"@odata.type" = "#microsoft.graph.iPv6CidrRange"
41+
CidrAddress = "2001:0:9d38:90d6:0:0:0:0/63"
42+
}
43+
)
44+
}
45+
46+
New-MgIdentityConditionalAccessNamedLocation -BodyParameter $params
1647
17-
{{ Add description here }}
48+
Id CreatedDateTime DisplayName ModifiedDateTime
49+
-- --------------- ----------- ----------------
50+
0824dbaf-6277-4db0-8112-b29fd356f2c4 6/13/2022 8:41:38 AM Untrusted IP named location 6/13/2022 8:41:38 AM
51+
```
1852

53+
This example creates an Ip named location.
Lines changed: 86 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,95 @@
1-
### Example 1: {{ Add title here }}
1+
### Example 1: Require MFA to access Exchange Online outside of trusted locations
2+
23
```powershell
3-
PS C:\> {{ Add code here }}
4+
Connect-MgGraph -Scopes 'Policy.ReadWrite.ConditionalAccess'
5+
6+
7+
$params = @{
8+
DisplayName = "Access to EXO requires MFA"
9+
State = "enabled"
10+
Conditions = @{
11+
ClientAppTypes = @(
12+
"mobileAppsAndDesktopClients"
13+
"browser"
14+
)
15+
Applications = @{
16+
IncludeApplications = @(
17+
"b457cbac-03cb-4b15-9eef-79f24f8d3247"
18+
)
19+
}
20+
Users = @{
21+
IncludeGroups = @(
22+
"f39e2655-3fae-43ad-94e2-c2b593cfc473"
23+
)
24+
}
25+
Locations = @{
26+
IncludeLocations = @(
27+
"All"
28+
)
29+
ExcludeLocations = @(
30+
"AllTrusted"
31+
)
32+
}
33+
}
34+
GrantControls = @{
35+
Operator = "OR"
36+
BuiltInControls = @(
37+
"mfa"
38+
)
39+
}
40+
}
441
5-
{{ Add output here }}
42+
New-MgIdentityConditionalAccessPolicy -BodyParameter $params
43+
44+
Id CreatedDateTime Description DisplayName ModifiedDateTime State
45+
-- --------------- ----------- ----------- ---------------- -----
46+
1c9afd06-3f59-464e-a6d9-193d99764a01 7/29/2022 9:46:18 AM Access to EXO requires MFA enabled
647
```
748

8-
{{ Add description here }}
49+
This example shows a request to require multi-factor authentication for access to Exchange Online from modern authentication clients outside of trusted locations for a particular group.
50+
51+
### Example 2: Block access to Exchange Online from non-trusted regions
952

10-
### Example 2: {{ Add title here }}
1153
```powershell
12-
PS C:\> {{ Add code here }}
54+
Connect-MgGraph -Scopes 'Policy.ReadWrite.ConditionalAccess'
1355
14-
{{ Add output here }}
15-
```
56+
$params = @{
57+
DisplayName = "Block access to EXO non-trusted regions."
58+
State = "enabled"
59+
Conditions = @{
60+
ClientAppTypes = @(
61+
"all"
62+
)
63+
Applications = @{
64+
IncludeApplications = @(
65+
"b457cbac-03cb-4b15-9eef-79f24f8d3247"
66+
)
67+
}
68+
Users = @{
69+
IncludeGroups = @(
70+
"f39e2655-3fae-43ad-94e2-c2b593cfc473"
71+
)
72+
}
73+
Locations = @{
74+
IncludeLocations = @(
75+
"0824dbaf-6277-4db0-8112-b29fd356f2c4"
76+
)
77+
}
78+
}
79+
GrantControls = @{
80+
Operator = "OR"
81+
BuiltInControls = @(
82+
"block"
83+
)
84+
}
85+
}
86+
87+
New-MgIdentityConditionalAccessPolicy -BodyParameter $params
1688
17-
{{ Add description here }}
89+
Id CreatedDateTime Description DisplayName ModifiedDateTime State
90+
-- --------------- ----------- ----------- ---------------- -----
91+
61c7530f-5c1d-44b2-a972-4ae658b7a9ac 7/29/2022 10:03:30 AM Block access to EXO non-trusted regions. enabled
92+
93+
```
1894

95+
This example shows a request to block access to Exchange Online from non-trusted/unknown regions. This example assumes that the named location `0824dbaf-6277-4db0-8112-b29fd356f2c4` corresponds to a list of non-trusted/unknown regions.
Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
1-
### Example 1: {{ Add title here }}
2-
```powershell
3-
PS C:\> {{ Add code here }}
4-
5-
{{ Add output here }}
6-
```
1+
### Example 1: Remove a named location
72

8-
{{ Add description here }}
9-
10-
### Example 2: {{ Add title here }}
113
```powershell
12-
PS C:\> {{ Add code here }}
4+
Connect-MgGraph -Scopes 'Policy.ReadWrite.ConditionalAccess'
135
14-
{{ Add output here }}
6+
Remove-MgIdentityConditionalAccessNamedLocation -NamedLocationId $namedLocationId
157
```
168

17-
{{ Add description here }}
18-
9+
This example removed the named location specified by `$namedLocationId`.
Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
1-
### Example 1: {{ Add title here }}
2-
```powershell
3-
PS C:\> {{ Add code here }}
4-
5-
{{ Add output here }}
6-
```
1+
### Example 1: Remove a conditional access policy
72

8-
{{ Add description here }}
9-
10-
### Example 2: {{ Add title here }}
113
```powershell
12-
PS C:\> {{ Add code here }}
4+
Connect-MgGraph -Scopes 'Policy.ReadWrite.ConditionalAccess'
135
14-
{{ Add output here }}
6+
Remove-MgIdentityConditionalAccessPolicy -ConditionalAccessPolicyId $conditionalAccessPolicyId
157
```
168

17-
{{ Add description here }}
18-
9+
This example deletes the conditional access policy specified by `$conditionalAccessPolicyId`.
Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
### Example 1: {{ Add title here }}
2-
```powershell
3-
PS C:\> {{ Add code here }}
4-
5-
{{ Add output here }}
6-
```
1+
### Example 1: Update a country named location by adding to the list of countries
72

8-
{{ Add description here }}
9-
10-
### Example 2: {{ Add title here }}
113
```powershell
12-
PS C:\> {{ Add code here }}
4+
Connect-MgGraph -Scopes 'Policy.ReadWrite.ConditionalAccess'
135
14-
{{ Add output here }}
15-
```
6+
$params = @{
7+
"@odata.type" = "#microsoft.graph.countryNamedLocation"
8+
DisplayName = "Named location with unknown countries and regions"
9+
CountriesAndRegions = @(
10+
"US"
11+
"XK"
12+
"ID"
13+
"CA"
14+
)
15+
IncludeUnknownCountriesAndRegions = $true
16+
}
1617
17-
{{ Add description here }}
18+
Update-MgIdentityConditionalAccessNamedLocation -NamedLocationId '1f0fd623-bf8f-4003-9627-32a68c3cdcc1' -BodyParameter $params
19+
```
1820

21+
This example updates the details of an existing named location. Supply the values of the relevant fields that should be updated. In this example, `ID` and `CA` are added in the list of countries.
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: Add sign in risk levels to an existing conditional access policy
72

8-
{{ Add description here }}
9-
10-
### Example 2: {{ Add title here }}
113
```powershell
12-
PS C:\> {{ Add code here }}
4+
Connect-MgGraph -Scopes 'Policy.ReadWrite.ConditionalAccess'
5+
6+
$params = @{
7+
Conditions = @{
8+
SignInRiskLevels = @(
9+
"high"
10+
"medium"
11+
"low"
12+
)
13+
}
14+
}
1315
14-
{{ Add output here }}
16+
Update-MgIdentityConditionalAccessPolicy -ConditionalAccessPolicyId '61c7530f-5c1d-44b2-a972-4ae658b7a9ac' -BodyParameter $params
1517
```
1618

17-
{{ Add description here }}
18-
19+
This example updates and existing access policy to add the sign in risk levels.

0 commit comments

Comments
 (0)