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

Notifications

Announcements

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

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard