diff --git a/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-ExecOffboardingMailboxPermissions.ps1 b/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-ExecOffboardingMailboxPermissions.ps1 index 91660576876c..e1497d902ce1 100644 --- a/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-ExecOffboardingMailboxPermissions.ps1 +++ b/Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-ExecOffboardingMailboxPermissions.ps1 @@ -6,8 +6,6 @@ function Push-ExecOffboardingMailboxPermissions { param( $Item ) - $Mailboxes = New-ExoRequest -tenantid $Item.TenantFilter -cmdlet 'get-mailbox' -Select UserPrincipalName - foreach ($Mailbox in $Mailboxes) { - Remove-CIPPMailboxPermissions -PermissionsLevel @('FullAccess', 'SendAs', 'SendOnBehalf') -userid $Mailbox.UserPrincipalName -AccessUser $Item.User -TenantFilter $Item.TenantFilter -APIName $APINAME -ExecutingUser $Item.executingUser - } + + Remove-CIPPMailboxPermissions -PermissionsLevel @('FullAccess', 'SendAs', 'SendOnBehalf') -userid 'AllUsers' -AccessUser $Item.User -TenantFilter $Item.TenantFilter -APIName $Item.APINAME -ExecutingUser $Item.ExecutingUser } diff --git a/Modules/CIPPCore/Public/Invoke-CIPPOffboardingJob.ps1 b/Modules/CIPPCore/Public/Invoke-CIPPOffboardingJob.ps1 index a4c2f7a7686e..1a3e31826978 100644 --- a/Modules/CIPPCore/Public/Invoke-CIPPOffboardingJob.ps1 +++ b/Modules/CIPPCore/Public/Invoke-CIPPOffboardingJob.ps1 @@ -88,7 +88,8 @@ function Invoke-CIPPOffboardingJob { 'FunctionName' = 'ExecOffboardingMailboxPermissions' 'TenantFilter' = $TenantFilter 'User' = $Username - 'executingUser' = $ExecutingUser + 'ExecutingUser' = $ExecutingUser + 'APINAME' = $APINAME 'QueueId' = $Queue.RowKey } ) diff --git a/Modules/CIPPCore/Public/Remove-CIPPMailboxPermissions.ps1 b/Modules/CIPPCore/Public/Remove-CIPPMailboxPermissions.ps1 index 1e039e8bb8e5..5b416a37a911 100644 --- a/Modules/CIPPCore/Public/Remove-CIPPMailboxPermissions.ps1 +++ b/Modules/CIPPCore/Public/Remove-CIPPMailboxPermissions.ps1 @@ -11,7 +11,7 @@ function Remove-CIPPMailboxPermissions { try { if ($userid -eq 'AllUsers') { - $Mailboxes = New-ExoRequest -tenantid $TenantFilter -cmdlet 'get-mailbox' + $Mailboxes = New-ExoRequest -tenantid $TenantFilter -cmdlet 'Get-Mailbox' -Property UserPrincipalName $Mailboxes | ForEach-Object -Parallel { Import-Module '.\Modules\AzBobbyTables' Import-Module '.\Modules\CIPPCore'