Setting up a local Sitecore environment using the Sitecore Install Framework (SIF) is a powerful way to automate complex deployments. However, as any developer knows, local configurations can sometimes go sideways. Whether you encountered an error during a Sitecore 9 or 10 installation, or you simply need to decommission an old instance to free up resources, knowing how to cleanly uninstall Sitecore is just as important as knowing how to install it.
In the early days of SIF, there was no native 'uninstall' command, leaving developers to manually scrub their systems. Thankfully, modern versions of the framework have introduced built-in capabilities, and the community has developed robust scripts to handle the edge cases. In this guide, you will learn the official SIF method for uninstallation, as well as a comprehensive manual process for when the automated tools aren't enough.
Using the Native SIF Uninstall Command
If you are using SIF version 2.1 or later, you have access to a built-in uninstallation task. This is the most reliable method because it uses the same configuration logic that created the instance to tear it down. Before you begin, ensure your framework is up to date by running Update-Module SitecoreInstallFramework in an administrative PowerShell window.
To use the native uninstallation feature, you will need the original configuration files used for the installation (such as the XP0-SingleDeveloper.ps1 script). Instead of running the standard install command, you will pivot to the uninstall command.
Step 1: Update Your Script
Open your XP0-SingleDeveloper.ps1 file. You will notice the command at the bottom usually looks like this:
Install-SitecoreConfiguration @singleDevParams
To remove the instance, simply change the cmdlet to:
Uninstall-SitecoreConfiguration @singleDevParams
Step 2: Execute with Caution
When you run the script with the Uninstall prefix, SIF reverses the tasks defined in the JSON configuration files. It will attempt to stop services, remove IIS sites, and drop databases. Note that you may need to provide the administrative SQL password if it wasn't hardcoded in your parameters file.
Manual Uninstallation: The Comprehensive Checklist
Sometimes SIF scripts fail mid-way, or you may be working with an older version of Sitecore (like early 9.0 releases) where the uninstall command is less reliable. In these scenarios, a manual cleanup is required to ensure your environment remains stable for future installs. Follow these steps in order to fully scrub an instance from your machine.
1. Remove Windows Services
xConnect instances typically install two specific Windows services that must be removed manually if SIF doesn't catch them. Open PowerShell as an Administrator and run:
# Replace [Prefix] with your instance prefix (e.g., xp0Demo)
sc.exe delete "[Prefix].xconnect-MarketingAutomationService"
sc.exe delete "[Prefix].xconnect-IndexWorker"
2. Clean Up IIS and Webroots
Open the Internet Information Services (IIS) Manager. You need to remove both the Website and the associated Application Pool for your Sitecore site and the xConnect site.
Once the sites are removed in IIS, navigate to your webroot folder (usually C:\inetpub\wwwroot) and delete the physical folders. If you encounter "File in Use" errors, ensure you have stopped the IIS server or closed any open config files in your code editor.
3. Drop SQL Server Databases
Connect to your SQL Server instance using SQL Server Management Studio (SSMS). You will see a suite of databases prefixed with your instance name (e.g., xp0Demo_Core, xp0Demo_Master, etc.). You can highlight these and delete them, ensuring you check the box to "Close existing connections."
Alternatively, you can use a SQL script to drop them in bulk:
DECLARE @Sql NVARCHAR(MAX) = '';
SELECT @Sql += 'DROP DATABASE [' + name + '];' + CHAR(13)
FROM sys.databases
WHERE name LIKE 'xp0Demo%'
EXEC sp_executesql @Sql;
4. Remove Solr Cores and Indexes
Sitecore creates several cores within your Solr instance. To remove them:
1. Stop the Solr service.
2. Navigate to your Solr server folder (e.g., C:\solr\solr-x.x.x\server\solr).
3. Delete the folders prefixed with your instance name.
4. Restart the Solr service.
Automating Cleanup with Custom JSON Configurations
For DevOps engineers who frequently spin up and tear down environments, creating a dedicated uninstall.json is a best practice. This allows you to define custom tasks like removing SSL certificates or cleaning the hosts file which standard SIF might miss.
Here is an example of how you can structure a custom uninstallation task in a JSON configuration file:
{
"Tasks": {
"RemoveWebsites": {
"Type": "RemoveWebsite",
"Params": {
"Name": "[variable('Site.Name')]"
}
},
"RemoveAppPools": {
"Type": "RemoveWebAppPool",
"Params": {
"Name": "[variable('Site.Name')]"
}
},
"RemoveDatabases": {
"Type": "Sql",
"Params": {
"InputFile": "./dropdatabases.sql",
"ConnectionString": "[variable('Sql.ConnectionString')]",
"Variable": "[concat('prefix=', parameter('Prefix'))]"
}
}
}
}
By referencing this JSON in your PowerShell script, you create a repeatable, one-click destruction process for your development sandboxes.
Frequently Asked Questions
Can I just overwrite an existing Sitecore installation?
Generally, no. If you try to run SIF over an existing instance, you will likely encounter errors regarding existing databases, IIS site name conflicts, or locked files. It is always better to perform a clean uninstall of the databases and IIS sites before re-running SIF.
What happens to my SSL certificates after uninstallation?
Standard SIF uninstallation often leaves the self-signed SSL certificates in the Windows Certificate Store. To remove these, open certlm.msc, navigate to Personal > Certificates, and delete the certificates matching your instance's DNS names. This prevents your store from becoming cluttered over time.
Why does the xConnect service fail to delete?
This usually happens because the service is still running or a process (like a log viewer or PowerShell window) is hooked into it. Ensure you stop the service first using Stop-Service before attempting the sc.exe delete command.
Wrapping Up
Uninstalling Sitecore doesn't have to be a headache. While modern SIF versions provide the Uninstall-SitecoreConfiguration command to handle the heavy lifting, knowing the manual steps ensures you can recover from even the most broken installations. Always remember to clean up your Solr cores and SSL certificates to keep your development machine running efficiently. By mastering both the installation and uninstallation of the Sitecore Install Framework, you gain full control over your development lifecycle.