Skip to content

Commit 79ea116

Browse files
authored
Merge pull request KelvinTegelaar#1338 from Ren-Roros-Digital/fixgroup
fix: fix group deployment
2 parents d50b06d + cd9600a commit 79ea116

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardGroupTemplate.ps1

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,17 @@ function Invoke-CIPPStandardGroupTemplate {
4747
'mailNickname' = $groupobj.username
4848
mailEnabled = [bool]$false
4949
securityEnabled = [bool]$true
50-
isAssignableToRole = [bool]($groupobj | Where-Object -Property groupType -EQ 'AzureRole')
51-
50+
}
51+
if ($groupobj.groupType -eq 'AzureRole') {
52+
$BodyToship | Add-Member -NotePropertyName 'isAssignableToRole' -NotePropertyValue $true
5253
}
5354
if ($groupobj.membershipRules) {
5455
$BodyToship | Add-Member -NotePropertyName 'membershipRule' -NotePropertyValue ($groupobj.membershipRules)
5556
$BodyToship | Add-Member -NotePropertyName 'groupTypes' -NotePropertyValue @('DynamicMembership')
5657
$BodyToship | Add-Member -NotePropertyName 'membershipRuleProcessingState' -NotePropertyValue 'On'
5758
}
5859
if (!$CheckExististing) {
60+
$ActionType = 'create'
5961
if ($groupobj.groupType -in 'Generic', 'azurerole', 'dynamic') {
6062
$GraphRequest = New-GraphPostRequest -uri 'https://graph.microsoft.com/beta/groups' -tenantid $tenant -type POST -body (ConvertTo-Json -InputObject $BodyToship -Depth 10) -verbose
6163
} else {
@@ -80,6 +82,7 @@ function Invoke-CIPPStandardGroupTemplate {
8082
}
8183
Write-LogMessage -API 'Standards' -tenant $tenant -message "Created group $($groupobj.displayname) with id $($GraphRequest.id) " -Sev 'Info'
8284
} else {
85+
$ActionType = 'update'
8386
if ($groupobj.groupType -in 'Generic', 'azurerole', 'dynamic') {
8487
$GraphRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/beta/groups/$($CheckExististing.id)" -tenantid $tenant -type PATCH -body (ConvertTo-Json -InputObject $BodyToship -Depth 10) -verbose
8588
} else {
@@ -107,10 +110,8 @@ function Invoke-CIPPStandardGroupTemplate {
107110
}
108111
} catch {
109112
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message
110-
Write-LogMessage -API 'Standards' -tenant $tenant -message "Failed to create group: $ErrorMessage" -sev 'Error'
113+
Write-LogMessage -API 'Standards' -tenant $tenant -message "Failed to $ActionType group $($groupobj.displayname). Error: $ErrorMessage" -sev 'Error'
111114
}
112115
}
113-
114-
115116
}
116117
}

0 commit comments

Comments
 (0)