Skip to content

Commit bfe1388

Browse files
Merge pull request KelvinTegelaar#1681 from kris6673/visibility
Feat: Add support for setting group visibility in Microsoft 365 groups
2 parents 3962aab + 029b690 commit bfe1388

File tree

1 file changed

+14
-0
lines changed
  • Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Identity/Administration/Groups

1 file changed

+14
-0
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Identity/Administration/Groups/Invoke-EditGroup.ps1

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,20 @@ function Invoke-EditGroup {
371371
}
372372
}
373373

374+
# Only process visibility if it was explicitly sent for Microsoft 365 groups
375+
if ($GroupType -eq 'Microsoft 365' -and -not [string]::IsNullOrWhiteSpace($UserObj.visibility)) {
376+
try {
377+
$VisibilityValue = $UserObj.visibility
378+
$null = New-GraphPOSTRequest -uri "https://graph.microsoft.com/beta/groups/$($GroupID)" -type PATCH -tenantid $TenantId -body (@{'visibility' = $VisibilityValue } | ConvertTo-Json)
379+
380+
$Results.Add("Set group visibility to $VisibilityValue for $($GroupName).")
381+
} catch {
382+
$ErrorMessage = Get-CippException -Exception $_
383+
Write-Warning "Error in visibility: $($ErrorMessage.NormalizedError) - $($_.InvocationInfo.ScriptLineNumber)"
384+
$Results.Add("Failed to set group visibility for $($GroupName): $($ErrorMessage.NormalizedError)")
385+
}
386+
}
387+
374388
# Only process sendCopies if it was explicitly sent
375389
if ($null -ne $UserObj.sendCopies) {
376390
try {

0 commit comments

Comments
 (0)