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

Community site session details

Session Id : +9FDOVesQrgJkJHrji3ytG
Power Automate - Power Automate Desktop
Unanswered

Need help on creating a flow

Like (0) ShareShare
ReportReport
Posted on 21 Jun 2024 05:20:53 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,206 Super User 2025 Season 2 on 24 Jun 2024 at 17:19:09
    Re: Need help on creating a flow

    @NathanAlvares24 

     

    In the previous suggestions, I provided clear hints on how to approach this.

     

    @krishnanln 

     

    Please understand that community members won't create a complete flow for your use case; they will only assist in developing the logic. Even if you're new to this, it's important to attempt some actions on your own and address any issues that arise.

     

    The suggestion I provided above is quite straightforward. Please follow it and inform me if you encounter any problems during implementation.

     


    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 🚀

  • NathanAlvares24 Profile Picture
    1,673 Moderator on 24 Jun 2024 at 14:24:59
    Re: Need help on creating a flow

    Hi @krishnanln !

     

    I am afraid I don't have the solution.

     

    Please follow Deenuji's approach instead.

     

    Sorry once again.

  • krishnanln Profile Picture
    14 on 24 Jun 2024 at 07:37:49
    Re: Need help on creating a flow

    Hi Nathan,

    I get the below error now when executing 

     

    >>     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

    >> }

    >> 

    WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'.

    PackageManagement\Install-Package : No match was found for the specified search criteria and module name

    'Microsoft.PowerApps.Administration.PowerShell'. Try Get-PSRepository to see all available registered module

    repositories.

    At C:\Program Files (x86)\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21

    + ...          $null = PackageManagement\Install-Package @PSBoundParameters

    +                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        + CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Ex

       ception

        + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

     

    WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'.

    PackageManagement\Install-Package : No match was found for the specified search criteria and module name

    'Microsoft.PowerApps.PowerShell'. Try Get-PSRepository to see all available registered module repositories.

    At C:\Program Files (x86)\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21

    + ...          $null = PackageManagement\Install-Package @PSBoundParameters

    +                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        + CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Ex

       ception

        + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

     

    WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'.

    PackageManagement\Install-Package : No match was found for the specified search criteria and module name

    'ImportExcel'. Try Get-PSRepository to see all available registered module repositories.

    At C:\Program Files (x86)\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21

    + ...          $null = PackageManagement\Install-Package @PSBoundParameters

    +                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        + CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Ex

       ception

        + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

     

    PS C:\WINDOWS\system32>

  • krishnanln Profile Picture
    14 on 24 Jun 2024 at 06:50:28
    Re: Need help on creating a flow

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

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

     

    Please help.

  • krishnanln Profile Picture
    14 on 21 Jun 2024 at 09:59:06
    Re: Need help on creating a flow

    Hi Deenuji,

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

  • krishnanln Profile Picture
    14 on 21 Jun 2024 at 09:57:26
    Re: Need help on creating a flow

    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 21 Jun 2024 at 09:46:46
    Re: Need help on creating a flow

    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.

  • Deenuji_Loganathan_ Profile Picture
    6,206 Super User 2025 Season 2 on 21 Jun 2024 at 09:42:41
    Re: Need help on creating a flow

    @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 🚀

  • NathanAlvares24 Profile Picture
    1,673 Moderator on 21 Jun 2024 at 09:41:09
    Re: Need help on creating a flow

    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.

  • krishnanln Profile Picture
    14 on 21 Jun 2024 at 07:55:41
    Re: Need help on creating a flow

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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

MS.Ragavendar – Community Spotlight

We are honored to recognize Ragavendar Swaminatha Subramanian as our September…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 783 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 515 Moderator

#3
trice602 Profile Picture

trice602 299 Super User 2025 Season 2

Last 30 days Overall leaderboard
Loading complete