Restore your deleted, non-solution canvas app via PowerShell

Restoring a standalone (non-solution) canvas app using PowerShell involves leveraging the Power Apps Administration PowerShell module. Here’s a breakdown of the process:

Prerequisites:

  • PowerShell Modules: Ensure you have the Microsoft.PowerApps.Administration.PowerShell and Microsoft.PowerApps.PowerShell modules installed.
  • Permissions: You must have appropriate permissions to manage canvas apps in your Power Apps environment.

Steps:

  1. Connect to Power Apps: PowerShellAdd-PowerAppsAccount This command will prompt you to authenticate with your Power Apps credentials.
  2. Get Deleted Apps: PowerShellGet-AdminApp -EnvironmentName "YourEnvironmentName" -Deleted Replace "YourEnvironmentName" with the actual name of your Power Apps environment. This command retrieves a list of deleted canvas apps within that environment.
  3. Identify the App:
    • Examine the output of the Get-AdminApp command.
    • Locate the app you want to restore.
    • Note the AppName (the app’s GUID).
  4. Restore the App: PowerShellRestore-AdminApp -EnvironmentName "YourEnvironmentName" -AppName "AppGUID" Replace "YourEnvironmentName" with your environment name and "AppGUID" with the AppName you noted in the previous step.

Example:

PowerShell

Add-PowerAppsAccount

$environmentName = "MyDevEnvironment"
$deletedApps = Get-AdminApp -EnvironmentName $environmentName -Deleted

if ($deletedApps) {
    Write-Host "Deleted Canvas Apps:"
    $deletedApps | Format-Table DisplayName, AppName, LastModifiedTime

    $appToRestore = Read-Host "Enter the AppName (GUID) of the app to restore"

    Restore-AdminApp -EnvironmentName $environmentName -AppName $appToRestore

    Write-Host "Canvas app restored successfully."
} else {
    Write-Host "No deleted canvas apps found."
}

Explanation:

  • The script begins by connecting to your Power Apps account.
  • It then retrieves a list of deleted canvas apps from the specified environment.
  • It displays the deleted apps, including their display names and GUIDs.
  • The user is prompted to enter the GUID of the app to restore.
  • The Restore-AdminApp command is used to restore the selected app.
  • The script also includes error handeling, to inform the user if no deleted apps are found.

Important Notes:

  • Ensure you have the correct environment name and app GUID.
  • The restoration process might take some time.
  • It is always best practice to add canvas apps into solutions, so they are easier to manage, and backup.
  • Keep your PowerShell modules up to date.

By following these steps, you can effectively restore deleted standalone canvas apps using PowerShell.


Discover more from PowerBites

Subscribe to get the latest posts sent to your email.

Leave a comment