Skip to content

Commit 846df85

Browse files
Improvements to rule management for tenants
1 parent 88bfdc9 commit 846df85

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-ListMailboxRulesQueue.ps1

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,20 @@ function Push-ListMailboxRulesQueue {
1212

1313
$Table = Get-CIPPTable -TableName cachembxrules
1414
try {
15-
$Rules = New-ExoRequest -tenantid $domainName -cmdlet 'Get-Mailbox' -Select 'userPrincipalName,GUID' | ForEach-Object -Parallel {
16-
Import-Module CIPPCore
17-
$MbxRules = New-ExoRequest -Anchor $_.UserPrincipalName -tenantid $using:domainName -cmdlet 'Get-InboxRule' -cmdParams @{Mailbox = $_.GUID; IncludeHidden = $true } | Where-Object { $_.Name -ne 'Junk E-Mail Rule' -and $_.Name -notlike 'Microsoft.Exchange.OOF.*' }
18-
foreach ($Rule in $MbxRules) {
19-
$Rule | Add-Member -NotePropertyName 'UserPrincipalName' -NotePropertyValue $_.userPrincipalName
20-
$Rule
15+
$Mailboxes = New-ExoRequest -tenantid $domainName -cmdlet 'Get-Mailbox' -Select 'userPrincipalName,GUID'
16+
$Request = $Mailboxes | ForEach-Object {
17+
@{
18+
OperationGuid = $_.UserPrincipalName
19+
CmdletInput = @{
20+
CmdletName = 'Get-InboxRule'
21+
Parameters = @{
22+
Mailbox = $_.UserPrincipalName
23+
}
24+
}
2125
}
2226
}
27+
28+
$Rules = New-ExoBulkRequest -tenantid $domainName -cmdletArray @($Request) | Where-Object { $_.Identity }
2329
if (($Rules | Measure-Object).Count -gt 0) {
2430
$GraphRequest = foreach ($Rule in $Rules) {
2531
[PSCustomObject]@{

0 commit comments

Comments
 (0)