How to Completely Delete A Workflow With PowerShell

Since there doesn't seem to be a blog on this anywhere that I could find, I decided to do this on my own.  Why do I need to do this?  Because of this older blog post about a bug in SharePoint:

The migrate user command doesn't do everything that it should when moving from one domain to another.  In this case, a user had activated the workflow feature, the files are created and tagged to that user.  It is done in such a way that the migrateuser command is not able to update the user's actual acccountname (such as DOMAINAlias) in various places.  This presents a problem as that user cannot be resolved as their is not trust between the new AD and old AD.  This causes the above bug to come into play and the issue of not being able to create sites because of "user could not be found" error a reality.  So is it possible to script a fix for this? 

Yup…but it requires a bit of magic.  Since I can't seem to find any good object model method to completely delete a workflow, I went back to trusty ole sharepoint designer and "Fiddled" the traffic.  It does a super simple post to:

POST https://topleveldns/siteurl/_vti_bin/_vti_aut/author.dll 

It includes a must have header of:

X-Vermeer-Content-Type: application/x-www-form-urlencoded

 With a content body of:


This will fully delete a workflow from a site.  The next step is to then deactivate and reactive the workflow feature that will re-create the workflows – THIS SHOULD BE RUN AS THE SYSTEM ACCOUNT!.  The main parts of the script is this:

function DeleteWorkflow($url, $name)
    $uri = new-object System.Uri("")
    $localPath = $uri.localpath.replace("/","%2f")
    $name = $name.replace("-","%2d").replace(" ", "+")
    $postData = "method=remove+documents%3a14%2e0%2e0%2e4730&service%5fname=" + $localPath + "&url%5flist=%5b%5fcatalogs%2fwfpub%2f" + $name + "%5d"
    $isVermeerRequest = $true
    $res = DoPost $($url + "/_vti_bin/_vti_aut/author.dll") $postData ""   

function RemoveAndActivateWorkflows($url)
    DeleteWorkflow $url "Approval – SharePoint 2010"
    DeleteWorkflow $url "Collect Feedback – SharePoint 2010"
    DeleteWorkflow $url "Collect Signatures – SharePoint 2010"
    Disable-spfeature -url $url -identity "0af5989a-3aea-4519-8ab0-85d91abe39ff" -confirm:$false   
    enable-spfeature -url $url -identity "0af5989a-3aea-4519-8ab0-85d91abe39ff" -confirm:$false   

RemoveAndActivateWorkflows "http://topleveldns/siteurl"


O365 Search – Deleting Tenant Level Result Types

I have a really big client on the east coast.  We are automating the deployment of many of the search components in O365, very cool stuff.  However, not everything is hugs and kisses.  Turns out when you import a search configuration at the tenant level, you may import some Result Types.  Unfortunately, there is no link on the main Search page for the tenant admin that will let you delete these result types.

That does not mean it doesn't exist.  It does…you just have to guess where it is:


Bam…you can now delete any result types you imported… weird that the link is not available on the main search admin page.