I've been playing with the creation of Sitecore 9 instances, however I keep running into issues (which is not related to my question), but as I fix various things related to my local configuration, I would like to remove existing instances that failed to complete successfully using the SIF (Sitecore Install Framework). Is there a command already implemented that will automatically do this or will I need to create something that will do this?
-
There is an example how to uninstall Sitecore 8, and we are working on extending this scripts to uninstall Sitecore 9. We create a Select-Website function that will gather all information from connectionstring.config and pass to uninstall script.– Robson AutomatorMar 19, 2018 at 13:22
-
I now have a video that specifically talks about how to manually uninstall a Sitecore 9 instance: youtu.be/bI-cFDKXPfA– Dylan YoungApr 20, 2018 at 14:00
10 Answers
SIF 2.x now has this functionality built in as mentioned in the release notes.
There was an issue with it in 2.0, but it was fixed in 2.1.
To run it,
- Update SIF with
Update-Module SitecoreInstallFramework
if you don't have at least SIF 2.1 - If you don't already have it, Download the "XP0 Configuration files 9.1.1 rev. 002459.zip". I've specified a specific version here as it uses SIF 2.1+, but it should support any sitecore 9.0 and 9.1 installation. This is part of the On prem packages for XP Single.
- Unzip and Open the
XP0-SingleDeveloper.ps1
file, fill in all the parameters (some are optional for uninstalling) and change theInstall-SitecoreConfiguration
toUninstall-SitecoreConfiguration
There is not currently such a command. I wish there was.
In general terms to uninstall, you will need to:
- Remove the two xConnect windows services (with
sc delete [servicename]
) - Remove the Sitecore and xConnect webroots
- Remove the databases from SQL Server
If all you wish to do is overwrite an existing SIF-installed instance, removing the databases and re-running SIF should be sufficient if it's like the preview was.
-
4
-
4To add: HOST entries and IIS website definitions need to be removed as well. Nov 14, 2017 at 19:32
@Dylan Young, did you solved the uninstall problem ?
Manual way to uninstall an instance of Siteocre 9 involves few steps, but it is not that bad. Assuming that your installation instance is prefixed withxp0Demo
then:
- Remove the two xConnect windows services (with
sc.exe delete [servicename]
in poweshell as administrator or in cmd.exe as administrator too)xp0Demo.xconnect-MarketingAutomationService
xp0Demo.xconnect-IndexWorker
- Remove the Sitecore and xConnect website and application pools from IIS
- Remove the Sitecore and xConnect webroots
- Remove the databases from SQL Server prefixed with
xp0Demo
- Stop the Sorl service and remove the indexes prefiex with
xp0Demo
from folderc:\solr\solr-6.6.2\server\solr\
- Hosts entries that are prefixed with
xp0Demo
should be removed too
Also I've tested the procedure on a Sitecore 9 update 1 and its exactly the same, not changes required.
In here https://xtremdev.wordpress.com/2018/01/09/sitecore-9-uninstall-my-take/ you can see all details about uninstall of Sitecore 9, in a post that I've wrote, including details for SIF-less uninstall.
The first thing that you need to start with gathering all information about what should be uninstalled. In an easy way you can select a website to uninstall:
$selectedWebSite = (Get-WebSite | Out-GridView -Title "Please select website to uninstall" -OutputMode Single )
Base on this you have information about Website and App Pool to remove, you also have a physical path to remove
$physicalPath = [System.Environment]::ExpandEnvironmentVariables($selectedWebSite.physicalPath)
SIF comes with tasks to manage AppPool and Website Invoke-ManageAppPoolTask, Invoke-ManageWebsiteTask. We extend this with a 'remove' feature.
'remove' {
try
{
Get-WebAppPoolState -Name $Name
Write-Verbose "Stopping App Pool '$Name'"
Stop-WebAppPool -Name $Name
Write-Verbose "Removing App Pool '$Name'"
Remove-WebAppPool -Name $name
}
catch
{
Write-Warning -Message "App Pool $Name not exist"
}
}
'remove'{
try
{
Get-WebsiteState -Name $Name
Write-Verbose "Stopping Website '$Name'"
Stop-Website -Name $Name
Write-Verbose "Removing Website '$Name'"
Remove-Website -Name $Name
}
catch
{
Write-Warning "Site '$Name' not exist."
}
}
You also need to remove databases and users.The best place to find information about this is connectionstring.config.
Then you just to delete databases and users. A good example how to collect those data is here Select-Website
To delete database just invoke a simple command with parameters
Invoke-SQLcmd -ServerInstance $SQLServerName -Query ("DROP DATABASE [" + $database + "]")
Ready to use tasks to remove users and databases are here https://github.com/SoftServeInc/SitecoreInstallExtensions/blob/master/SitecoreInstallExtensions/Tasks/SqlTasks.ps1
Thomas Eldblom put together a nice package using Sitecore Extensions to install and uninstall an instance of Sitecore. I find this works great for me and my dev instances.
You really have to familiarize yourself with it. But it is a nifty way to install and uninstall Sitecore.
https://github.com/Eldblom/sifdemos
Parameters.ps1
Parameters pulls together all the locations and files like normal.
# General Args
$prefix = 'sugcon_xm0'
$configsRoot = Join-Path $PSScriptRoot Configs
$packagesRoot = Join-Path $PSScriptRoot Packages
$licenseFilePath = Join-Path $PSScriptRoot '..\\license.xml'
$sqlServer = '.'
### Sitecore ###
# Install Sitecore
$sitecoreStandalone = @{
Path = Join-Path $configsRoot sitecore-xm0.json
Package = Join-Path $packagesRoot 'Sitecore 9.0.1 rev. 171219 (OnPrem)_single.scwdp.zip'
LicenseFile = $licenseFilePath
SqlDbPrefix = $prefix
SiteName = $prefix
SqlServer = $sqlServer
}
Uninstall.ps1
Nice simple ps1 to bring it all together and execute the SIF configuration task.
# Bring parameters into scope
. $PSScriptRoot\parameters.ps1
$uninstallArgs = @{
Path = Join-Path $configsRoot "uninstall.json"
Prefix = $prefix
SqlServer = $sqlServer
}
Install-SitecoreConfiguration @uninstallArgs
Uninstall JSON
Json task doco to detail what to uninstall using the SIF task manager.
// 20180824164803
// https://raw.githubusercontent.com/Eldblom/sifdemos/master/2_xm0/Configs/uninstall.json
{
"Parameters": {
"Prefix": {
"Type": "string",
"Description": "Prefix used for sites, solr, databases etc"
},
"SqlAdminUser": {
"Type": "string",
"DefaultValue": "sa",
"Description": "The Sql admin user account to use when installing databases."
},
"SqlAdminPassword": {
"Type": "string",
"DefaultValue": "12345",
"Description": "The Sql admin password to use when installing databases."
},
"SqlServer": {
"Type": "string",
"DefaultValue": ".\\SQL2016",
"Description": "The Sql Server where databases will be installed."
}
},
"Variables": {
"All.With.Prefix": "[concat(parameter('Prefix'),'*')]",
"Install.Path": "[joinpath(environment('SystemDrive'), 'inetpub', 'wwwroot',variable('All.With.Prefix'))]",
"Sql.ConnectionString": "[sqlconnectionstring(parameter('SqlServer'), '', parameter('SqlAdminUser'), parameter('SqlAdminPassword'))]",
"Sql.DropDatabasesScript": "[resolvepath('..\\5_uninstall\\dropdatabases.sql')]"
},
"Tasks": {
"RemoveWebsites": {
"Type": "RemoveWebsite",
"Params": {
"Name": "[variable('All.With.Prefix')]"
}
},
"RemoveAppPools": {
"Type": "RemoveWebAppPool",
"Params": {
"Name": "[variable('All.With.Prefix')]"
}
},
"RemoveServices": {
"Type": "RemoveService",
"Params": {
"Name": "[variable('All.With.Prefix')]"
}
},
"RemoveInstalledContent": {
"Type": "Remove",
"Params": {
"Path": "[variable('Install.Path')]",
"Recurse": true
}
},
"RemoveDatabases": {
"Type": "Sql",
"Params": {
"InputFile": "[variable('Sql.DropDatabasesScript')]",
"ConnectionString": "[variable('Sql.ConnectionString')]",
"Variable": "[concat('prefix=', parameter('prefix'), '%')]",
"OutputSqlErrors": true,
"Verbose": true
}
}
},
"Modules": [
"SqlServer",
"..\\5_uninstall\\extensions.psm1"
]
}
As Kam Figy mentioned, there is no current command available in SIF to do such a thing. I would also add that in order to avoid getting Process-in-use type errors, ensure that the sites/ app-pools in IIS are stopped and that the Solr Cores are removed. Also make sure that the two services are completely removed - remove any processes in Task Manager that may be lingering!
I was having the exact same experience that you described though, so I wrote a small and rudimentary script to remove the various services, processes and websites running in order to get you back to a clean environment.
It is very much a WIP but let me know if it's helpful!
-
I think alot of people will have this issue. And others might want an easy way to remove an instance. Similar features to what was present in SIM. Oct 25, 2017 at 18:36
I follow it in following 4 steps.
- Open SIM, delete the instance from there, select "no" for removing database
- Stop Solr Service, delete solr core from the folder, start Solr Service
- Open SQL Server, delete all related databases in bulk using script https://stackoverflow.com/a/3281190/3959541
- Delete XConnect site from IIS
-
Sitecore 9 instance has more than that. SIM does not not cover all of them. You need to ensure to remove MA Windows Services and Application User created by SIF if you want to use SIM to remove other artifacts. Apr 2, 2019 at 19:01
if you want SIF to support uninstalling a Sitecore instance, please file a support ticket at https://support.sitecore.net/helpdesk/ and ask to link it with a feature request #204173
, and #250404
if you want it to repairs / reinstalls.
I hope this script can help to automate removing all those artifacts https://github.com/medkrimi/UninstallSitecore/blob/master/uninstall.ps1
It removes :
- Sitecore Website
- Hosts
- Sitecore files
- SQL Databases
- SSL Certificates (Make sure your are not sharing them between diffirent instance if you are in dev.local)
- Solr Cores
- Application Users
Delete the Sitecore instance folder from C:\inetpub\wwwroot and Solr Folder.
Run PowerShell as Admin and use SC.exe delete and delete Sitecore and Solr services .
Delete Sites from IIS
Delete the database from SQL (Optional)
Done !!!
If you get any error deleting the root folder in step 1 then stop Sitecore services and stop sites from IIS. Checkout this link and get Step by Step solution https://sitecoresolutionsbynikhil.blogspot.com/2023/04/sitecore-uninstall.html
-
Link only answers do not meet the guidelines for SSE, also if you are promoting your own blog you need to I dictate that when linking.– Richard Seal ♦Apr 24 at 14:08