SIF Module to Uninstall Sitecore 9

Dark Lords of the SIF

Sitecore developers and architects working in Sitecore 9 have been getting to grips with the Sitecore Install Framework (SIF) that launched with the new version of Sitecore earlier in the year. Its been just over a month or so since release and already plenty of extensions, guides and modules have been produced by the community. In an attempt to get to grips with SIF in more detail, I have re-written the little uninstall script that I wrote a while ago to work within SIF as a module, as well as giving it a long-overdue overhaul (my PowerShell still leaves a lot to be desired). This should allow developers working on local instances to install and uninstall XP0 configurations of Sitecore all within the warm PowerShell-blue haze of SIF.

SIF is also a Powerful Goddess and wife of Thor, God of thunder, so there's that.

Sitecore Install Framework 1.0 rev. 171003
###Making a Module

A SIF extension is made up of a PowerShell module (.psm1) file and a JSON config file. To run a task through SIF, the cmdlet to be called is Install-SitecoreConfiguration, passing the config file in as a parameter. Tasks are implemented as cmdlets and their parameters are usually specified in the JSON config.

The PowerShell Bit

The PowerShell module may perform whatever functions are required of it, but at the foot of the module the function Register-SitecoreInstallExtension must be called, passing in the command, Type, and task name as follows:

Register-SitecoreInstallExtension -Command Uninstall-Sitecore -As UninstallSitecore -Type Task

The JSON Bit

As discussed in the SIF installation and configuration Guide, the JSON configuration must specify the paramaters, variables, modules and tasks to which it pertains - this will then allow SIF to work out what tasks it is being told to perform. Parameters represent the values that will be passed in to the tasks, and are probably the most commonly altered by developers to suit their needs:

{ "Parameters" : { "Prefix": { "Type": "string", "DefaultValue": "sc9", "Description": "The prefix used by the Sitecore instance" } } }

Each config should reference the module(s) that should be loaded when it is used:

"Modules" : [ "Uninstall-SitecoreConfiguration.psm1" ],

Finally, each task to be run is listed along with the parameters that will be used:

"Tasks" : { "Uninstall Sitecore Installation" : { "Type" : "UninstallSitecore", "Params" : { "Prefix" : "[parameter('Prefix')]", "SitecoreSiteName" : "[parameter('SitecoreSiteName')]", "PathToSolrCores" : "[parameter('PathToSolrCores')]", "PathToWebRoot" : "[parameter('PathToWebRoot')]", "SolrService" : "[parameter('SolrService')]", "SqlAccount" : "[parameter('SqlAccount')]", "SqlPassword" : "[parameter('SqlPassword')]", "SqlServer" : "[parameter('SqlServer')]" } } }

The Source

The full source for the module and config file are available here if it will be of any use. Merry SIFmas!