How to bulk cancel site workflows with a status of "Error Occurred"

Following up on the article How to bulk cancel list workflows with a status of "Error Occurred". Here is a way to bulk cancel site workflows.

To use the script, replace http://contoso.com with the URL of the site you wish to execute the script against.

Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue  
function Cancel-SPWorkflow(){  
PARAM  
(
[Parameter(ValueFromPipeline=$true)] [Microsoft.SharePoint.Workflow.SPWorkflow] $SPWorkflow
)

BEGIN {  
  }

END {  
}

PROCESS {  
        [Microsoft.SharePoint.Workflow.SPWorkflowManager]::CancelWorkflow($SPworkflow)
    }
}
$(Get-SPWeb http://contoso.com).Workflows | where {[String]$_.StatusText -match [String]"Error"} | Cancel-SPWorkflow