Skip to content

Commit

Permalink
fix: addtogroup functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnDuprey committed Mar 3, 2025
1 parent 426427c commit 11de9ef
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,14 @@ Function Invoke-EditUser {
if ($AddToGroups) {
$AddToGroups | ForEach-Object {

$GroupType = $_.value.groupType -join ','
$GroupID = $_.value.groupid
$GroupName = $_.value.groupName
$GroupType = $_.addedFields.calculatedGroupType
$GroupID = $_.value
$GroupName = $_.label
Write-Host "About to add $($UserObj.userPrincipalName) to $GroupName. Group ID is: $GroupID and type is: $GroupType"

try {

if ($GroupType -eq 'Distribution list' -or $GroupType -eq 'Mail-Enabled Security') {

Write-Host 'Adding to group via Add-DistributionGroupMember '
$Params = @{ Identity = $GroupID; Member = $UserObj.id; BypassSecurityGroupManagerCheck = $true }
$null = New-ExoRequest -tenantid $UserObj.tenantFilter -cmdlet 'Add-DistributionGroupMember' -cmdParams $params -UseSystemMailbox $true
Expand Down

0 comments on commit 11de9ef

Please sign in to comment.