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 with the URL of the site you wish to execute the script against.

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


END {  

$(Get-SPWeb | where {[String]$_.StatusText -match [String]"Error"} | Cancel-SPWorkflow