Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Running a PowerShell Script for a Sharepoint Workflow

$
0
0

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."

}


Viewing all articles
Browse latest Browse all 6937

Trending Articles