I am trying to list the inbox rules on all the mailboxes in my O365 (approx 6,000). We had a malware infection and a bunch of people had a rule get created that marked messages as read and moved them to the archive folder. I need to find who has these rules still applied so I can clear them.<\/p>\n
Microsoft tells me to use Start-RobustCloudCommand.ps1, but I can 't figure out how to convert my existing script to use that. I’ve been told to use invoke-command and Scriptblock, but all the examples I can find kinda suck.<\/p>\n
My existing script takes ~6 hours and only reports the first handful of people. I created a dummy mailbox with some rules just to check, and it never shows them so I know my script is not completing.<\/p>\n
Here is what I am running:<\/p>\n
$users = get-mailbox -resultsize unlimited\n\n$results=ForEach ($user in $users)\n{\n $rules = get-InboxRule -Mailbox $user.name\n if ($rules.length -gt 0) {\n echo \"\"\n echo $user.name\n echo \"\"\n $rules | select name, priority, description | fl\n echo \"\"\n }\n} \n$results | Out-File -FilePath \"D:\\Downloads\\Powershell Scripts\\rulesoutput.txt\" -Append\n<\/code><\/pre>\nAnyone know a better way to run this against multi thousand mailboxes, or have a better way all together?<\/p>","upvoteCount":1,"answerCount":9,"datePublished":"2018-06-28T17:53:39.000Z","author":{"@type":"Person","name":"dannymainprize","url":"https://community.spiceworks.com/u/dannymainprize"},"acceptedAnswer":{"@type":"Answer","text":"
I doubt this is faser though.<\/p>\n
get-mailbox -resultsize unlimited |\nforeach {\n Write-Verbose \"Checking $($_.alias)...\" -Verbose\n $inboxrule = get-inboxrule -Mailbox $_.alias \n if ($inboxrule) {\n foreach($rule in $inboxrule){\n [PSCustomObject]@{\n Mailbox = $_.alias\n Rulename = $rule.name\n Rulepriority = $rule.priority\n Ruledescription = $rule.description\n }\n }\n }\n} | \nExport-csv \"$env:userprofile\\desktop\\export.csv\" -NoTypeInformation\n<\/code><\/pre>","upvoteCount":2,"datePublished":"2018-06-28T19:03:58.000Z","url":"https://community.spiceworks.com/t/get-inboxrule-on-multiple-mailboxes/659414/3","author":{"@type":"Person","name":"Neally","url":"https://community.spiceworks.com/u/Neally"}},"suggestedAnswer":[{"@type":"Answer","text":"I am trying to list the inbox rules on all the mailboxes in my O365 (approx 6,000). We had a malware infection and a bunch of people had a rule get created that marked messages as read and moved them to the archive folder. I need to find who has these rules still applied so I can clear them.<\/p>\n
Microsoft tells me to use Start-RobustCloudCommand.ps1, but I can 't figure out how to convert my existing script to use that. I’ve been told to use invoke-command and Scriptblock, but all the examples I can find kinda suck.<\/p>\n
My existing script takes ~6 hours and only reports the first handful of people. I created a dummy mailbox with some rules just to check, and it never shows them so I know my script is not completing.<\/p>\n
Here is what I am running:<\/p>\n
$users = get-mailbox -resultsize unlimited\n\n$results=ForEach ($user in $users)\n{\n $rules = get-InboxRule -Mailbox $user.name\n if ($rules.length -gt 0) {\n echo \"\"\n echo $user.name\n echo \"\"\n $rules | select name, priority, description | fl\n echo \"\"\n }\n} \n$results | Out-File -FilePath \"D:\\Downloads\\Powershell Scripts\\rulesoutput.txt\" -Append\n<\/code><\/pre>\nAnyone know a better way to run this against multi thousand mailboxes, or have a better way all together?<\/p>","upvoteCount":1,"datePublished":"2018-06-28T17:53:39.000Z","url":"https://community.spiceworks.com/t/get-inboxrule-on-multiple-mailboxes/659414/1","author":{"@type":"Person","name":"dannymainprize","url":"https://community.spiceworks.com/u/dannymainprize"}},{"@type":"Answer","text":"
If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>