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 / Need help on creating ...
Power Automate
Unanswered

Need help on creating a flow

(0) ShareShare
ReportReport
Posted on by 14

Hi people,

 

I need help on complete the below task.

 

Get all the flow details like list of flows in the environment and actions available in each of those flows and write the output to an excel file. It should be done using Powershell scripting.

I have the same question (0)
  • Deenuji_Loganathan_ Profile Picture
    6,250 Moderator on at

    @krishnanln 

     

    Recently power automate desktop introduced Dataverse packages where you get the process table where it has all the flow details and along with your flow code.  You can consume those Dataverse table action and get your flow details and convert into dashboard using PowerShell scripting.

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

  • krishnanln Profile Picture
    14 on at

    I was able to get the script but in the script, its calling api.powerautomate.com/environments/.. to get these information, but i need to pass bearer access token to get details from the API. How do i generate the access token automatically every time and pass it to the script ?

  • Deenuji_Loganathan_ Profile Picture
    6,250 Moderator on at

    @krishnanln 

     

    How is your solution architecture looks like? Are you trying to build this solution using power automate desktop or any other stuffs? 

  • krishnanln Profile Picture
    14 on at

    Yes, im using Power Automate Desktop to execute the powershell script.

  • NathanAlvares24 Profile Picture
    1,714 Moderator on at

    Hi @krishnanln !

     

    Is it possible for you to try this:

    NathanAlvares24_0-1718962505105.png

     

    Code:

     

    @@copilotGeneratedAction: 'False'
    Scripting.RunPowershellScript.RunPowershellScript Script: $'''# Install the required modules if not already installed
    if (-not (Get-Module -ListAvailable -Name Microsoft.PowerApps.Administration.PowerShell)) {
     Install-Module -Name Microsoft.PowerApps.Administration.PowerShell -Force -AllowClobber
    }
    if (-not (Get-Module -ListAvailable -Name Microsoft.PowerApps.PowerShell)) {
     Install-Module -Name Microsoft.PowerApps.PowerShell -Force -AllowClobber
    }
    if (-not (Get-Module -ListAvailable -Name ImportExcel)) {
     Install-Module -Name ImportExcel -Force -AllowClobber
    }
    
    # Import necessary modules
    Import-Module Microsoft.PowerApps.Administration.PowerShell -Verbose
    Import-Module Microsoft.PowerApps.PowerShell -Verbose
    Import-Module ImportExcel''' ScriptOutput=> PowershellOutput3 ScriptError=> ScriptError3
    @@copilotGeneratedAction: 'False'
    Scripting.RunPowershellScript.RunPowershellScript Script: $'''# Function to handle errors
    function Handle-Error {
     param ($ErrorMessage)
     Write-Host \"Error: $ErrorMessage\" -ForegroundColor Red
     exit 1
    }
    
    try {
     # Connect to Power Automate
     Add-PowerAppsAccount
    } catch {
     Handle-Error \"Failed to connect to Power Automate: $_\"
    }
    
    try {
     # List all environments
     $environments = Get-AdminPowerAppEnvironment
     $environments
    
     # Get list of all flows in the specific environment
     $environmentName = \'your-environment-name\' # Replace with the correct environment name
     $flows = Get-AdminFlow -EnvironmentName $environmentName
    
     if ($flows.Count -eq 0) {
     Handle-Error \"No flows found in the environment $environmentName.\"
     }
    
     # Create a list to store flow details
     $flowDetails = @()
    
     foreach ($flow in $flows) {
     # Get flow details
     $flowId = $flow.FlowName
     $flowName = $flow.DisplayName
    
     # Get actions for each flow
     $actions = Get-FlowRunAction -EnvironmentName $environmentName -FlowName $flowId -RunName (Get-FlowRuns -EnvironmentName $environmentName -FlowName $flowId | Select-Object -First 1).Name
    
     foreach ($action in $actions) {
     $actionDetails = @{
     FlowName = $flowName
     ActionName = $action.DisplayName
     ActionType = $action.Name
     }
     $flowDetails += $actionDetails
     }
     }
    } catch {
     Handle-Error \"Failed to retrieve flows or actions: $_\"
    }
    
    try {
     # Define the output file path
     $outputFilePath = \"C:\\Users\\JohnDoe\\Desktop\\FlowsAndActions.xlsx\"
    
     # Write the data to Excel
     $flowDetails | Export-Excel -Path $outputFilePath -AutoSize
     Write-Host \"Flow details exported to $outputFilePath\" -ForegroundColor Green
    } catch {
     Handle-Error \"Failed to export data to Excel: $_\"
    }''' ScriptOutput=> PowershellOutput4 ScriptError=> ScriptError4
    @@copilotGeneratedAction: 'False'
    Scripting.RunPowershellScript.RunPowershellScript Script: $'''# List available cmdlets from the PowerApps modules
    Get-Command -Module Microsoft.PowerApps.Administration.PowerShell
    Get-Command -Module Microsoft.PowerApps.PowerShell''' ScriptOutput=> PowershellOutput5 ScriptError=> ScriptError5
    

     

     

    Remember in the above code, just replace your environment name and the path of your excel file where you put on your machine.

     

    Just remember before running this code, first run this following code in your PowerShell in Administrator mode:

     

    # Install the required modules
    Install-Module -Name Microsoft.PowerApps.Administration.PowerShell -Force -AllowClobber
    Install-Module -Name Microsoft.PowerApps.PowerShell -Force -AllowClobber
    Install-Module -Name ImportExcel -Force -AllowClobber

     

     

    I have this excel file on my desktop:

    NathanAlvares24_1-1718962826531.png

     

    Just attach screenshots if you get errors or any success.

     

    Just let me know if this works. I hope this helps.

  • Deenuji_Loganathan_ Profile Picture
    6,250 Moderator on at

    @krishnanln 

     

    Then have you tried my above suggested approach?

    You don't really require any API call for this use case. Instead just get all the flow details from dataverse table called "Process" and once you get the required details you can pass into powershell and convert them into dashboard or report.

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

  • krishnanln Profile Picture
    14 on at

    I tried to get the solution using copilot in PAD tool. It gave a solution connecting to https://api.powerautomate.com/environments/environmentname/flows.

    but its not working.

     

    I need to get the list of flows and actions in the flows using powershell scripting. Kindly please help.

  • krishnanln Profile Picture
    14 on at

    Hi Nathan,

     

    Thank you so much. When i tried to execute the 3 lines to install module. It first asked for the confirmation to install nuget package and then it threw the error "no match was found for the specific search criteria and module name.". i couldnt attach it as im working with the script on my client desktop environment.

  • krishnanln Profile Picture
    14 on at

    Hi Deenuji,

    Im not sure how to do this as im new to PAD. Please help.

  • krishnanln Profile Picture
    14 on at

    Hello Nathan, I get the error "The string is missing the terminator:'. " in below

    $environmentName = '\efdb000-23cf-efaa-a49e-0c3a434jeee'

     

    Please help.

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 594

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 281 Super User 2026 Season 1

Last 30 days Overall leaderboard