Skip to content

Commit 84eb43a

Browse files
committed
Update Invoke-ExecCAExclusion.ps1
1 parent 6e53124 commit 84eb43a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Conditional/Invoke-ExecCAExclusion.ps1

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ function Invoke-ExecCAExclusion {
2222
$PolicyId = $Request.Body.PolicyId
2323
$ExclusionType = $Request.Body.ExclusionType
2424

25-
$Policy = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/identity/conditionalAccess/policies/$($PolicyId)?`$select=id,displayName" -tenantid $TenantFilter
26-
2725
if ($Users) {
2826
$UserID = $Users.value
2927
$Username = $Users.addedFields.userPrincipalName -join ', '
@@ -32,6 +30,14 @@ function Invoke-ExecCAExclusion {
3230
$Username = (New-GraphGetRequest -uri "https://graph.microsoft.com/v1.0/users/$($UserID)" -tenantid $TenantFilter).userPrincipalName
3331
}
3432
}
33+
34+
$Policy = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/identity/conditionalAccess/policies/$($PolicyId)?`$select=id,displayName" -tenantid $TenantFilter -asApp $true
35+
36+
if (-not $Policy) {
37+
throw "Policy with ID $PolicyId not found in tenant $TenantFilter."
38+
}
39+
40+
$PolicyName = $Policy.displayName
3541
if ($Request.Body.vacation -eq 'true') {
3642
$StartDate = $Request.Body.StartDate
3743
$EndDate = $Request.Body.EndDate

0 commit comments

Comments
 (0)