PowerPlatform : PowerAutomate – PowerShell script to list all PowerAutomates / Flows in a tenant and export to CSV file

PowerShell script to get all PowerAutomates from the tenant
PowerShell script to get all PowerAutomates from the tenant

Hi All,

Greetings for the day 🙂 LIFE IS BEAUTIFUL 🙂

Today one more PowerShell script along with Power Automate

Background : My management need all the list of Power Automates implemented in the tenant so this script born 🙂 Even though small script but sharing. SHARING IS CARING

Details / Steps :

  • We will use Get-AdminFlow CMDLET to return list of all flows in tenant
  • Permissions required :
    • Global Administrator
    • Environment Administrator
    • Power Platform Administrator
$powerAutomates = Get-AdminFlow

  • Once we have list of Power Automates from tenant, we will loop through each Power Automate and get the details as
# loop through each power automate
foreach ($powerAutomate in $powerAutomates)
{

    #Get the user from Created By field of Power Automate
    $user = Get-UsersOrGroupsFromGraph -ObjectId $powerAutomate.CreatedBy.userId

    #prepare the row to write the details in CSV file
    $row = @{
        ResourceType = 'PowerAutomate'
        DisplayName = $powerAutomate.displayName
        EnvironmentName = $powerAutomate.environmentName
        CreatedByEmail = $user.DisplayName
    }

    $powerAutomateListings+= $(new-object psobject -Property $row)
}

  • Lets see the PowerAutomate object details – which properties are exposed.
Fig : Power Platform – Power Automate – PowerShell script for fetching all Power Automates from the Tenant
  • Here we are using Get-UsersOrGroupsFromGraph CMDLET to get the user object. So that we can have user display name
Fig : Power Platform – Power Automate – PowerShell script for fetching all Power Automates from the Tenant – Getting user details from Power Automate created by field
  • Final step is write to CSV file using Export-Csv CMDLET

# output to file on given Path
$powerAutomateListings | Export-Csv -Path $Path

Complete PowerShell script:

<#  
    Outputs a .csv file of records that represent list of PowerAutomates from the tenant it is run in. Result feature records will include:
        - PowerAutomate display name
        - Environment Name
        - User display name who created the Power Automate
#>

param(
    [string]$Path = 'c:\List_PowerAutomate_Details.csv'
)
    
    #Get all PowerAutomates the Tenant - with proper respective permissions
        # Global Administrator
        # Environment Administrator
        # Power Platform Administrator

    $powerAutomates = Get-AdminFlow 

    $powerAutomateListings = @()

# loop through each power automate
foreach ($powerAutomate in $powerAutomates)
{

    #Get the user from Created By field of Power Automate
    $user = Get-UsersOrGroupsFromGraph -ObjectId $powerAutomate.CreatedBy.userId

    #prepare the row to write the details in CSV file
    $row = @{
        ResourceType = 'PowerAutomate'
        DisplayName = $powerAutomate.displayName
        EnvironmentName = $powerAutomate.environmentName
        CreatedByEmail = $user.DisplayName
    }
    $powerAutomateListings+= $(new-object psobject -Property $row)
}

# output to file on given Path
$powerAutomateListings | Export-Csv -Path $Path

Knowledge Junction has various PowerShell cmdlet in its Kitty, please have a look – https://knowledge-junction.in/category/technology-articles/powershell-cmdlets/

Thanks for reading 🙂 If its worth at least reading once, kindly please like and share 🙂 SHARE ING IS CARING 🙂

Prasham Sabadra

LIFE IS VERY BEAUTIFUL :) ENJOY THE WHOLE JOURNEY :) Founder of Knowledge Junction and live-beautiful-life.com, Author, Learner, Passionate Techie, avid reader. Certified Professional Workshop Facilitator / Public Speaker. Scrum Foundation Professional certificated. Motivational, Behavioral , Technical speaker. Speaks in various events including SharePoint Saturdays, Boot camps, Collages / Schools, local chapter. Can reach me for Microsoft 365, Azure, DevOps, SharePoint, Teams, Power Platform, JavaScript.

You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Microsoft 365

Subscribe now to keep reading and get access to the full archive.

Continue reading