Uninstall Script for Sitecore 10 and Commerce Instances

Currently, the Sitecore Commerce PS deploy Script has an uninstall cmdlet but there is not a way to uninstall both Commerce and Sitecore instances in one shot. So, I decided to put everything in one PS Script so that I can use it for my local development environment. Here is the output of a random execution I performed:

For reference, this is how my local websites are named. I need to ensure that the param values match each of these names in my PS Scripts:

Taking a few steps backward, if you check the deploy sitecore commerce PS Script (My-Deploy-Sitecore-Commerce.ps1), it is possible to uninstall commerce instance by just toggling the cmdlet in the PS deploy script: Change Install-SitecoreConfiguration to  Uninstall-SitecoreConfiguration:

Then, run the My-Deploy-Sitecore-Commerce.ps1 in PS admin mode  from the folder (location in my case - C:\sitecore\Sitecore.Commerce.WDP.2020.08-6.0.238\SIF.Sitecore.Commerce.5.0.49). My Commerce scripts (folder) for reference:
Once you run the uninstall, don't forget to change the line back to Install-SitecoreConfiguration before the next run of installation! The other approach would be to create an Uninstall script right at the time when you create the install script for a site so that you have the same param values but just the Install-SitecoreConfiguration /  UnInstall-SitecoreConfiguration line is different for the concerned script.

In case of Vanilla Sitecore uninstall, you can use the XP0-SingleDeveloper.ps1 after updating the param values in the top. In case if you are using the XP0-SingleDeveloper.ps1, here are the areas you need to change:


Comment the install command and uncomment the uninstall command:

Better option would be to create separate Install and Uninstall scripts for each site so that you don't lose track of the param values as you build more websites locally.

Note that the Sitecore 10.0.0 rev. 004346 (Setup XP0 Developer Workstation rev. 1.2.0-r64).zip is unzipped in the location - C:\sitecore\Sitecore10.0.0. Placed the license file also in the same location -
Then, run the XP0-SingleDeveloper.ps1 from C:\sitecore\Sitecore10.0.0 in PS admin mode:



Just for the sake of it, I decided to put together a PS Script that does all the following in one shot rather than running two PS Scripts:

1. Stop and delete Commerce-related Services, Website, App Pools, folders and DBs
2. Stop and delete all Sitecore-related Services, Website, App Pools, folders and DBs
3. Delete Solr Service + folder

I decided to follow a silent approach and didn't want the script to stop just in case any of the items involved is not present or already deleted - by checking if the item or service already exists and delete only if it exists. Param values:

The script doesn't do the following:

1. Delete the website certificates 
2. Delete the Windows user created for Commerce 

I'm updating the script with regard to a few issues. So, this is still a work-in-progress. Use it at your own risk :)

References: 

Comments

Popular Posts