Skip to content

Commit 8bdf57c

Browse files
committed
Update Invoke-ExecCAExclusion.ps1
1 parent 84eb43a commit 8bdf57c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function Invoke-ExecCAExclusion {
1717
#If UserId is a guid, get the user's UPN
1818
$TenantFilter = $Request.Body.tenantFilter
1919
$UserID = $Request.Body.UserID
20+
$Username = $Request.Body.Username
2021
$Users = $Request.Body.Users
2122
$EndDate = $Request.Body.EndDate
2223
$PolicyId = $Request.Body.PolicyId
@@ -26,7 +27,7 @@ function Invoke-ExecCAExclusion {
2627
$UserID = $Users.value
2728
$Username = $Users.addedFields.userPrincipalName -join ', '
2829
} else {
29-
if ($UserID -match '^[a-f0-9]{8}-([a-f0-9]{4}-){3}[a-f0-9]{12}$') {
30+
if ($UserID -match '^[a-f0-9]{8}-([a-f0-9]{4}-){3}[a-f0-9]{12}$' -and -not $Username) {
3031
$Username = (New-GraphGetRequest -uri "https://graph.microsoft.com/v1.0/users/$($UserID)" -tenantid $TenantFilter).userPrincipalName
3132
}
3233
}

0 commit comments

Comments
 (0)