Restore your deleted, non-solution flows via PowerShell

Restoring a deleted cloud flow that isn’t part of a solution using PowerShell requires interacting with the Power Automate Management connectors via PowerShell. Here’s a breakdown of the process and the necessary steps:

Important Considerations:

  • Recovery Window: There’s a limited window for restoring deleted flows. After a certain period (typically 30 days), the flow is permanently deleted.
  • Permissions: You’ll need appropriate permissions within your Power Automate environment to perform these actions.
  • Module Installation: Ensure you have the Microsoft.PowerApps.Administration.PowerShell and Microsoft.PowerApps.PowerShell modules installed.

Steps:

  1. Connect to Power Apps: PowerShellAdd-PowerAppsAccount This command will prompt you to authenticate with your Power Apps credentials.
  2. Get Deleted Flows: PowerShellGet-AdminFlow -EnvironmentName "YourEnvironmentName" -Deleted Replace "YourEnvironmentName" with the actual name of your Power Automate environment. This command retrieves a list of deleted flows within that environment.
  3. Identify the Flow:
    • Examine the output of the Get-AdminFlow command.
    • Look for the flow you want to restore.
    • Note the FlowName (the flow’s GUID).
  4. Restore the Flow: PowerShellRestore-AdminFlow -EnvironmentName "YourEnvironmentName" -FlowName "FlowGUID" Replace "YourEnvironmentName" with your environment name and "FlowGUID" with the FlowName you noted in the previous step.

Example:

PowerShell

Add-PowerAppsAccount
$environmentName = "MyDevEnvironment"
$deletedFlows = Get-AdminFlow -EnvironmentName $environmentName -Deleted

if ($deletedFlows) {
    Write-Host "Deleted Flows:"
    $deletedFlows | Format-Table DisplayName, FlowName, LastModifiedTime

    $flowToRestore = Read-Host "Enter the FlowName (GUID) of the flow to restore"

    Restore-AdminFlow -EnvironmentName $environmentName -FlowName $flowToRestore

    Write-Host "Flow restored successfully."
} else {
    Write-Host "No deleted flows found."
}

Explanation:

  • The script first connects to your Power Apps account.
  • It then retrieves the list of deleted flows in the specified environment.
  • It displays the deleted flows, including their names and GUIDs.
  • The user is then prompted to enter the GUID of the flow to restore.
  • Finally, the Restore-AdminFlow command is used to restore the selected flow.
  • It also includes error handeling, to ensure that if no deleted flows are found, it informs the user.

Important Notes:

  • Ensure you have the correct environment name and flow GUID.
  • The restoration process might take some time, depending on the complexity of the flow.
  • It is best practice to always add your flows to solutions, this makes them much easier to manage, and backup.
  • If you are having issues with the powershell modules, ensure that they are up to date.

By following these steps, you can restore deleted cloud flows that are not part of a solution using PowerShell.


Discover more from PowerBites

Subscribe to get the latest posts sent to your email.

Leave a comment