I’ve been tinkering with the concept of a rollback script for Sitecore 9 and I’ve had to add a bit more functionality to SIF to handle this. This can be done by adding in custom modules to SIF, which, once you get the hang of it, is pretty easy.  The SIF Guide has some good starters and I’ve heard more is coming.

Here’s a custom module written to remove a folder:

Set-StrictMode -Version 2.0

Function Invoke-RemoveFolderTask {

	if(Test-Path $name) {
           Write-TaskInfo "Removing Folder {$name}" -Tag 'RemoveFolder'

           Remove-Item -path $name -recurse
	    Write-TaskInfo "Folder doesn't exist {$name}" -Tag 'RemoveFolder'
Register-SitecoreInstallExtension -Command Invoke-RemoveFolderTask -As RemoveFolder -Type Task

I wanted to call special attention to line 20. This is the actual command that loads the module to be accessible via SIF.  Your SIF Config file looks something like this:

// -------------------------------------------------------------------------- //
//         Sitecore Install Framework - XConnect Solr Configuration           //
//                                                                            //
//  Run this configuration on your Solr instance to configure the cores for   //
//  an XConnect deployment. If the cores exist, they will be overwritten.     //
//                                                                            //
//  NOTE: Only single line comments are accepted in configurations.           //
// -------------------------------------------------------------------------- //
    "Parameters": {
        // Parameters are values that may be passed when Install-SitecoreConfiguration is called.
        // Parameters must declare a Type and may declare a DefaultValue and Description.
        // Parameters with no DefaultValue are required when Install-SitecoreConfiguration is called.

        "Path": {
            "Type": "string",
            "DefaultValue": "C:\\PathToRemove",
            "Description": "Folder to remove."
    "Tasks": {
        // Tasks are separate units of work in a configuration.
        // Each task is an action that will be completed when Install-SitecoreConfiguration is called.
        // By default, tasks are applied in the order they are declared.
        // Tasks may reference Parameters, Variables, and config functions. 
			"Type": "RemoveFolder",
			"Params": {
				"Name": "[parameter('Path')]"

The important thing for flexibility here is the relative pathing in the Modules section.  The first code snippet is encapsulated in “Invoke-RemoveFolderTask.psm1” which is located in the same folder as the JSON Config.