We will learn to migrate non-solutions flows into a solution using PowerShell in Power Automate. Before we start, make sure to subscribe to CRM Crate so that you can stay up to date in the field of Power Platform.
Solutions serve the purpose of transporting applications and components between different environments or implementing a series of customizations in existing applications. A solution may encompass multiple applications along with additional components like site maps, tables, processes, web resources, choices, flows, and more.
Solutions serve as the mechanism for executing application lifecycle management (ALM) in Power Apps and other products within the Power Platform, including Power Automate.
Ways to Migrate non-solutions flows into a solution using PowerShell
This solution migrates non-solution cloud flows into Dataverse and integrates them into a Power App solution. This functionality is akin to a maker employing the “Add existing” capability to include an existing cloud flow into a solution, with the distinction that it enables an administrator to efficiently migrate multiple (or all) flows into Dataverse and subsequently into a solution.
Installing PowerShell for Power Platform Administrators
Follow the below procedure to install PowerShell for Power Platform administrators in your local machine.
- Run PowerShell as an administrator.
- Import or update the necessary module by using one of the following commands:
PowerShell Command: Install-Module -Name Microsoft.PowerApps.Administration.PowerShell
- Run the below command if you do not have Administrator rights in your local machine.
PowerShell Command: Save-Module -Name Microsoft.PowerApps.Administration.PowerShell -Path Import-Module -Name Microsoft.PowerApps.Administration.PowerShell
- If you receive a prompt to confirm the modification to the InstallationPolicy value of the repository, acknowledge [A] Yes to All modules by entering ‘A’ and pressing Enter for each module.
PowerShell scripts for migrating flows in Power Automate
Below are the PowerShell scripts which you can use for moving your flows into dedicated solutions.
Add-AdminFlowsToSolution -EnvironmentName ‘Environment GUID’
This script migrates all the non-solution flows in an environment into a default solution.
Add-AdminFlowsToSolution -EnvironmentName ”Environment GUID -FlowNames ‘Flow GUID’
This script only migrates the defined flows in an environment into a default solution.
Add-AdminFlowsToSolution -EnvironmentName ‘Environment GUID’ -SolutionId ‘Solution GUID’
This script migrates all the non-solution flows in an environment into a specific solution.
Add-AdminFlowsToSolution -EnvironmentName ‘Environment GUID’-SolutionId ‘Solution GUID’-Top 50
This script migrates top 50 non-solution flows into a specific solution as per the defination.