All Articles

Uninstalling a Sitecore instance installed with SIA

Introduction

Whenever a Sitecore installation fails or an instance takes up too much of my disk space, I end up uninstalling the Sitecore instance. I use the SIF scripts in the installation package to perform this task. This article describes the simplest way to automate Sitecore uninstall tasks with SIF.

Steps to be followed:

  1. Go to the package installation root on your File Explorer.

  2. Create a copy of the file XP0-SingleDeveloper.ps1.

  3. Rename it as Uninstall-XP0-SingleDeveloper.ps1.

    Sitecore Installation Package Folder

  4. Open the file Uninstall-XP0-SingleDeveloper.ps1 in an editor.

  5. Change the values of the below variables appropriately.

    # The Prefix that will be used on SOLR, Website and Database instances.
    $Prefix = "<prefix-provided-during-installation>"
    # The Password for the Sitecore Admin User. This will be regenerated if left on the default.
    $SitecoreAdminPassword = "<admin-password-provided-during-installation>"
    # The root folder with the license file and WDP files.
    $SCInstallRoot = "."
    # Root folder to install the site to. If left on the default [systemdrive]:\\inetpub\\wwwroot will be used
    $SitePhysicalRoot = ""
    # The name for the XConnect service.
    $XConnectSiteName = "$($prefix)xconnect.dev.local"
    # The Sitecore site instance name.
    $SitecoreSiteName = "$($prefix)sc.dev.local"
    # Identity Server site name
    $IdentityServerSiteName = "$($prefix)identityserver.dev.local"
    # The Path to the license file
    $LicenseFile = "$SCInstallRoot\license.xml"
    # The URL of the Solr Server
    # Change to Solr instance URL
    $SolrUrl = "https://localhost:8840/solr"
    # The Folder that Solr has been installed to.
    # Change to the path to your Solr instance
    $SolrRoot = "C:\Solr\solr-8.4.0"
    # The Name of the Solr Service.
    # Change to the name of your Solr instance
    $SolrService = "solr-8.4.0"
    # The DNS name or IP of the SQL Instance.
    # Change to your database server
    $SqlServer = "localhost"
    # A SQL user with sysadmin privileges.
    # Change if a different database user was used
    $SqlAdminUser = "sa"
    # The password for $SQLAdminUser.
    $SqlAdminPassword = "<sql-admin-user-password>"
  6. Change the below lines as mentioned:

    # Comment this line by adding # in the beginning
    
    #Install-SitecoreConfiguration @singleDeveloperParams *>&1 | Tee-Object XP0-SingleDeveloper.log
    
    # And Uncomment this line by removing the # in the beginning
    
    Uninstall-SitecoreConfiguration @singleDeveloperParams *>&1 | Tee-Object XP0-SingleDeveloper-Uninstall.log
  7. Run PowerShell as Administrator.

  8. Run the below command in PowerShell.

    cd '<Path\To\Installation Files>'
    .\Uninstall-XP0-SingleDeveloper.ps1

This should remove and clean up your websites, databases and indexes related to the specific instance.

Please feel free to post your questions/suggestions in the comments.

Happy Sitecoring!

Published Jul 20, 2021

Sitecore MVP Technology 2024-23. Web Developer with rich experience in Sitecore and ASP.NET MVC.