Powershell script works on the main site, but does not work on sub-sites in Sharepoint 2010. Assistance will be greatly appreciated.
# SharePoint.Workflow.Start-SPSiteWorkflow
param (
[string]$Url = "https://",
[string]$Workflow = "t1"
)
# get the workflow assocation from the target site/web
$site = Get-SPSite $Url
$culture = [System.Globalization.CultureInfo]::InvariantCulture
$wfAssociation = $site.RootWeb.WorkflowAssociations.GetAssociationByName($Workflow, $culture)
if ( $wfAssociation )
{
# initialize and optionally update association data
$assocData = $wfAssociation.AssociationData
# start the workflow
$wfRunOption = [Microsoft.SharePoint.Workflow.SPWorkflowRunOptions]::Asynchronous
$site.WorkflowManager.StartWorkflow($site, $wfAssociation, $assocData, $wfRunOption)
}
else
{
Write-Error "Workflow association not found on target web site."
}