web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Automating Exchange Re...
Power Automate
Unanswered

Automating Exchange Report

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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
I have the same question (0)
  • fraenK Profile Picture
    2,125 on at

    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/power-automate/desktop-flows/actions-reference/system#runpowershellscript

    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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 570

#2
Valantis Profile Picture

Valantis 405

#3
11manish Profile Picture

11manish 350

Last 30 days Overall leaderboard