We run a powershell script once a month to connect to exchange and pull the mailbox rules from every mailbox in our tenant. Below is the script we use. I want to automate this process - essentially have the automation run the report and automatically email the exported .csv file so that we don't have to do this manually every month. This can run on a VM in our virtual environment. Two places I'm getting hung up:
1) Connecting to exchange requires credentials - is there a way to pass those credentials to the command without having to manually log in?
2) The powershell script takes a good 10-15 minutes to run across our 700 mailboxes. How can I delay the automation between running the command and emailing the exported file?
Any help would be great. I'm new to power automate and not sure the best way to go about running this operation, so I'm open to ideas.
get-mailbox -resultsize unlimited | foreach { Write-Verbose "Checking $($_.alias)..." -Verbose $inboxrule = get-inboxrule -Mailbox $_.alias if ($inboxrule) { foreach($rule in $inboxrule){ [PSCustomObject]@{ Mailbox = $_.alias Rulename = $rule.name Rulepriority = $rule.priority Ruledescription = $rule.description } } } } | Export-csv "$env:userprofile\desktop\export.csv" -NoTypeInformation

Report
All responses (
Answers (