Skip to content
Rishan Solutions
Rishan Solutions
  • PowerApps
  • SharePoint online
    • Uncategorized
    • Uncategorized
  • PowerAutomate
Rishan Solutions
Latest Posts
  • Agentic AI: The Dawn of Autonomous Intelligence Revolutionizing 2025 June 24, 2025
  • Recursive Queries in T-SQL May 7, 2025
  • Generating Test Data with CROSS JOIN May 7, 2025
  • Working with Hierarchical Data May 7, 2025
  • Using TRY_CAST vs CAST May 7, 2025
  • Dynamic SQL Execution with sp_executesql May 7, 2025

Rolling Back Solution Deployments using PowerShell

Posted on March 24, 2025March 24, 2025 by Rishan Solutions

Loading

In Power Platform, solution deployments can sometimes introduce unexpected issues. Rolling back a solution deployment ensures stability in the environment by either reverting to a previous version or removing the faulty solution. Using PowerShell, you can automate this rollback process efficiently.


Step 1: Prerequisites

1.1 Install Required PowerShell Modules

Ensure the Power Platform PowerShell modules are installed:

Install-Module -Name Microsoft.PowerApps.Administration.PowerShell -Force
Install-Module -Name Microsoft.PowerApps.PowerShell -Force

1.2 Authenticate to Power Platform

Sign in to Power Platform using:

Add-PowerAppsAccount

1.3 Identify the Environment and Solution

Retrieve the environment name where the rollback needs to be performed:

Get-AdminPowerAppEnvironment | Select-Object DisplayName, EnvironmentName

Example Output:

DisplayName      EnvironmentName
------------ -----------------------------
ProductionEnv fedcba98-7654-3210-fedc-ba9876543210

Check available solutions in the environment:

Get-CrmSolutions -EnvironmentName "fedcba98-7654-3210-fedc-ba9876543210"

Example Output:

FriendlyName       UniqueName      Version
------------- ------------ ---------
MySolution MySolution 1.0.0.2
MySolution MySolution 1.0.0.1

Step 2: Rolling Back to a Previous Version

If a new managed solution version is causing issues, rollback by re-importing the previous version.

2.1 Export the Previous Version Before Deployment

Before deploying an update, always keep a backup copy of the previous version:

$envName = "fedcba98-7654-3210-fedc-ba9876543210"
$solutionName = "MySolution"
$backupPath = "C:\Solutions\Backup\$solutionName-1.0.0.1.zip"

Export-CrmSolution -SolutionName $solutionName -Managed -OutFile $backupPath -EnvironmentName $envName
Write-Host "Backup of version 1.0.0.1 created."

2.2 Remove the Faulty Version

To remove the problematic version:

Remove-CrmSolution -SolutionName "MySolution" -EnvironmentName "fedcba98-7654-3210-fedc-ba9876543210"
Write-Host "Solution 'MySolution' removed."

2.3 Re-Import the Previous Version

Re-import the previous stable version:

$previousSolutionPath = "C:\Solutions\Backup\MySolution-1.0.0.1.zip"

Import-CrmSolution -SolutionFilePath $previousSolutionPath -EnvironmentName "fedcba98-7654-3210-fedc-ba9876543210" -ImportMode "Upgrade"
Write-Host "Solution rolled back to version 1.0.0.1."

Step 3: Rolling Back by Restoring a Backup

If a solution update causes critical failures, restore the entire environment backup.

3.1 Retrieve Available Backups

Check for available backups using:

Get-AdminPowerAppEnvironmentBackups -EnvironmentName "fedcba98-7654-3210-fedc-ba9876543210"

Example Output:

BackupId                              CreatedOn
-------- -------------------
12345678-abcd-4321-efgh-87654321abcd 2025-03-20 12:00

3.2 Restore a Backup

Restore-AdminPowerAppEnvironment -EnvironmentName "fedcba98-7654-3210-fedc-ba9876543210" -BackupId "12345678-abcd-4321-efgh-87654321abcd"
Write-Host "Environment restored to backup taken on 2025-03-20."

This may take some time, depending on the environment size.


Step 4: Automating Solution Rollback

4.1 PowerShell Script for Automated Rollback

Save the following script as Rollback-Solution.ps1:

param (
[string]$envName = "fedcba98-7654-3210-fedc-ba9876543210",
[string]$solutionName = "MySolution",
[string]$backupPath = "C:\Solutions\Backup\$solutionName-1.0.0.1.zip"
)

# Authenticate
Add-PowerAppsAccount

# Remove Current Solution
Remove-CrmSolution -SolutionName $solutionName -EnvironmentName $envName
Write-Host "Solution '$solutionName' removed."

# Restore Previous Version
Import-CrmSolution -SolutionFilePath $backupPath -EnvironmentName $envName -ImportMode "Upgrade"
Write-Host "Solution '$solutionName' rolled back successfully."

Run this script:

powershell.exe -File "C:\Scripts\Rollback-Solution.ps1"

Step 5: Verifying the Rollback

Check the current solution version after rollback:

Get-CrmSolutions -EnvironmentName "fedcba98-7654-3210-fedc-ba9876543210" | Where-Object {$_.UniqueName -eq "MySolution"}

Expected Output:

FriendlyName       UniqueName      Version
------------- ------------ ---------
MySolution MySolution 1.0.0.1
Posted Under PNP PowerShellAPI monitoring Automating Power BI. Automating Power Platform Dataverse Dataverse Query Performance Flow Performance Monitoring Power Platform Performance Logs Performance Monitoring Power Apps Power AUtomate Power Bi Power BI Reports Power platform Power Platform Administration Power Platform Analytics Power Platform Best Practices Power Platform CI/CD Power Platform Compliance Power Platform Email Alerts Power Platform Governance Power Platform Logs Power Platform Optimization Power Platform Reports Power Platform Security Power Platform Troubleshooting Powershell PowerShell Automation Scheduled Tasks windows task scheduler

Post navigation

Handling window resize events
Automating Power Platform Performance Monitoring using PowerShell

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • Agentic AI: The Dawn of Autonomous Intelligence Revolutionizing 2025
  • Recursive Queries in T-SQL
  • Generating Test Data with CROSS JOIN
  • Working with Hierarchical Data
  • Using TRY_CAST vs CAST

Recent Comments

  1. Michael Francis on Search , Filter and Lookup in power apps
  2. A WordPress Commenter on Hello world!

Archives

  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • March 2024
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • June 2023
  • May 2023
  • April 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • January 2022

Categories

  • Active Directory
  • AI
  • AngularJS
  • Blockchain
  • Button
  • Buttons
  • Choice Column
  • Cloud
  • Cloud Computing
  • Data Science
  • Distribution List
  • DotNet
  • Dynamics365
  • Excel Desktop
  • Extended Reality (XR) – AR, VR, MR
  • Gallery
  • Icons
  • IoT
  • Java
  • Java Script
  • jQuery
  • Microsoft Teams
  • ML
  • MS Excel
  • MS Office 365
  • MS Word
  • Office 365
  • Outlook
  • PDF File
  • PNP PowerShell
  • Power BI
  • Power Pages
  • Power Platform
  • Power Virtual Agent
  • PowerApps
  • PowerAutomate
  • PowerPoint Desktop
  • PVA
  • Python
  • Quantum Computing
  • Radio button
  • ReactJS
  • Security Groups
  • SharePoint Document library
  • SharePoint online
  • SharePoint onpremise
  • SQL
  • SQL Server
  • Template
  • Uncategorized
  • Variable
  • Visio
  • Visual Studio code
  • Windows
© Rishan Solutions 2025 | Designed by PixaHive.com.
  • Rishan Solutions