27 November 2017

Easy UnInstall Sitecore 9

As being Sitecore developer, I do Sitecore Installations often. Earlier when we used to Install, it was relatively easy(1, 2, 3) to un-install Sitecore. Though it was never too easy, but still we can remove website by taking care of IIS node & couple of databases in local machine to get rid of old or corrupted Sitecore Instalations.

Recently Sitecore launched new Instalation experience, called it SIF(Sitecore Instalation Framework), many(Kam, Toby) of our MVP colleagues has already blogged about it on how to quickly learn & do it yourself. But with this new way, it introduces many moving pieces. So now it contains SSL Certificates, Solr Cores, Windows Services, multiple IIS websites and these can be less or more depend upon the type of Instalation(Topologies) you choose.

During my own learning, I failed with Sitecore 9 Instalations & end up having these zombies pieces like Certs, DB, Solr Core etc., I see this problem is not only with me, Kam did take a shot to it.

Well, I am trying to bring my own solution for same problem. Following is to summarise my solution in quick points:

  • Create Uniform PowerShell Script(Cmdlet) for Instalation.
    • I take this script straight from Sitecore Instalation Manual & made little modifications.
  • As part of this instalation script generate 'AntiInstance' file in JSON format.
    • As part of this modification I write code to generate this JSON file.
  • With help of 'AntiInstance' file & another Powershell script Un-Install the Sitecore Instance.
    • This should be run & forget as a forceful removal.
Key here are two PowerShell files which are still in WIP, you can find source code here, which I plan to complete over in nex few weekends.

Following are quick steps to Install & then Un-Install Sitecore, Here deliberately i will fail the Installation to mock incomplete Installations. 
  • Dump all files in one folder(as shown in Figure 1.1), for required topology, in this example I used xp0.
    • This folder should includes license file & two Powershell files. Powershell files you should get from GitHub.
Figure 1.1
  • Make sure that you use SitecoreInstall-Better.ps1 file for Instalation while updating all parameters stated at start of file(as shown in Figure 1.2).
    • Offcourse here, I assumed that you already have all pre-requisite(for example Solr on SSL) to Install Sitecore(Otherwise follow blogs stated earlier).
Figure 1.2
  • Install Sitecore while firing up above file after due changes. 
Figure 1.3
  • This should  result in In-Complete Installation.
Figure 1.4
  • Now let's Un-Install this Sitecore Instalation, while using Un-InstallSitecore.ps1 file. It will confirm before deleting Website root folders, to be quick pass A for 'Accept All'.
Figure 1.5
  • It should clear all mess which earlier Instalation script it left, for example certificate installed earlier deleted through this script as shown in Figure 1.6 & 1.7
Figure 1.6

Figure 1.7

Again this is not yet production ready & take it at your own risk. I will try to complete it for xp0 topology and will seek feedback to take it further, if this is right way to uninstall for actual adoption.

Let me know what you think about this, especially Kam.

No comments:

Post a Comment