Skip to content

Commit e142802

Browse files
committed
prevent empty permission scope from being pushed
1 parent 5f7a754 commit e142802

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Modules/CIPPCore/Public/Add-CIPPDelegatedPermission.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ function Add-CIPPDelegatedPermission {
114114
$OldScope = ($CurrentDelegatedScopes | Where-Object -Property Resourceid -EQ $svcPrincipalId.id)
115115

116116
if (!$OldScope) {
117+
if ([string]::IsNullOrEmpty($NewScope) -or $NewScope -eq ' ') {
118+
$Results.add("No delegated permissions to add for $($svcPrincipalId.displayName)")
119+
continue
120+
}
117121
try {
118122
$Createbody = @{
119123
clientId = $ourSVCPrincipal.id
@@ -147,6 +151,13 @@ function Add-CIPPDelegatedPermission {
147151
$Results.add("All delegated permissions exist for $($svcPrincipalId.displayName)")
148152
continue
149153
}
154+
155+
if ([string]::IsNullOrEmpty($NewScope) -or $NewScope -eq ' ') {
156+
# No permissions to update
157+
$Results.add("No delegated permissions to update for $($svcPrincipalId.displayName)")
158+
continue
159+
}
160+
150161
$Patchbody = @{
151162
scope = "$NewScope"
152163
} | ConvertTo-Json -Compress

0 commit comments

Comments
 (0)