File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -43,10 +43,12 @@ function New-CIPPBackupTask {
4343 }
4444 ' ca' {
4545 Measure-CippTask - TaskName ' ConditionalAccess' - EventName ' CIPP.BackupCompleted' - Script {
46+ $preloadedUsers = New-GraphGetRequest - uri " https://graph.microsoft.com/beta/users?`$ top=999&`$ select=displayName,id" - tenantid $TenantFilter
47+ $preloadedGroups = New-GraphGetRequest - uri " https://graph.microsoft.com/beta/groups?`$ top=999&`$ select=displayName,id" - tenantid $TenantFilter
4648 $Policies = New-GraphGetRequest - uri ' https://graph.microsoft.com/beta/conditionalAccess/policies?$top=999' - tenantid $TenantFilter - AsApp $true
4749 foreach ($policy in $policies ) {
4850 try {
49- New-CIPPCATemplate - TenantFilter $TenantFilter - JSON $policy
51+ New-CIPPCATemplate - TenantFilter $TenantFilter - JSON $policy - preloadedUsers $preloadedUsers - preloadedGroups $preloadedGroups
5052 } catch {
5153 " Failed to create a template of the Conditional Access Policy with ID: $ ( $policy.id ) . Error: $ ( $_.Exception.Message ) "
5254 }
Original file line number Diff line number Diff line change @@ -4,15 +4,25 @@ function New-CIPPCATemplate {
44 $TenantFilter ,
55 $JSON ,
66 $APIName = ' Add CIPP CA Template' ,
7- $Headers
7+ $Headers ,
8+ $preloadedUsers ,
9+ $preloadedGroups
810 )
911
1012 $JSON = ([pscustomobject ]$JSON ) | ForEach-Object {
1113 $NonEmptyProperties = $_.psobject.Properties | Where-Object { $null -ne $_.Value } | Select-Object - ExpandProperty Name
1214 $_ | Select-Object - Property $NonEmptyProperties
1315 }
14- $users = (New-GraphGetRequest - uri " https://graph.microsoft.com/beta/users?`$ top=999&`$ select=displayName,id" - tenantid $TenantFilter )
15- $groups = (New-GraphGetRequest - uri " https://graph.microsoft.com/beta/groups?`$ top=999&`$ select=displayName,id" - tenantid $TenantFilter )
16+ if ($preloadedUsers ) {
17+ $users = $preloadedUsers
18+ } else {
19+ $users = (New-GraphGetRequest - uri " https://graph.microsoft.com/beta/users?`$ top=999&`$ select=displayName,id" - tenantid $TenantFilter )
20+ }
21+ if ($preloadedGroups ) {
22+ $groups = $preloadedGroups
23+ } else {
24+ $groups = (New-GraphGetRequest - uri " https://graph.microsoft.com/beta/groups?`$ top=999&`$ select=displayName,id" - tenantid $TenantFilter )
25+ }
1626 $includelocations = New-Object System.Collections.ArrayList
1727 $IncludeJSON = foreach ($Location in $JSON.conditions.locations.includeLocations ) {
1828 $locationinfo = New-GraphGetRequest - uri ' https://graph.microsoft.com/beta/identity/conditionalAccess/namedLocations' - tenantid $TenantFilter | Where-Object - Property id -EQ $location | Select-Object * - ExcludeProperty id, * time*
You can’t perform that action at this time.
0 commit comments