Starting a SharePoint Designer site WorkFlow from PowerShell
I had to schedule a SharePoint Designer site workflow with a “no code” solution. Normally, when I need to set a scheduled workflow I will create a SharePoint timer job and schedule it to run. The requirement for this particular client meant I couldn't add any SharePoint code. This ruled out using a SharePoint timer job. A search on the Internet yielded no results and no one already had a PowerShell script created so I wrote one.
Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue function start-siteworkflow{ Param( [Parameter(Mandatory = $true, HelpMessage="Enter the Site URL that contains the site workflow")][string]$RootSite, [Parameter(Mandatory = $true,HelpMessage="Enter the name of the site workflow")][string]$workFlowName, [Parameter(Mandatory = $false, HelpMessage="Leave Blank")][AllowEmptyString()][string]$location ) $site = get-spsite $RootSite $web = $site.OpenWeb() $assoc = $web.WorkflowAssociations.GetAssociationByName($workFlowName, [CultureInfo]::'InvariantCulture') $params = [xml]"" $site.WorkFlowManager.StartWorkflow($location, $assoc, $params, 'Asynchronous') } start-siteworkflow