
Announcements
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
You can run your Powershell script from Power Automate Desktop and including login (depending on whatever Exchange deployment you have)
https://docs.microsoft.com/en-us/powershell/exchange/?view=exchange-ps
You can pass credentials through variables, just make sure you do it in a secure way through a credential manager e.g. CyberArk or https://powerusers.microsoft.com/t5/Webinars-and-Video-Gallery/Using-Sensitive-Text-In-Power-Automate-Desktop-Azure-Key-Vault/td-p/790556
After the script action you add the email action taking the export.csv.
Just scheduling is currently only supported through cloud flows: https://powerusers.microsoft.com/t5/Power-Automate-Ideas/Schedule-Power-Automate-Desktop-from-within-Windows-10/idi-p/847797