SharePoint Tech Blog


Associate a workflow to a SharePoint list using Powershell

Filed under: SharePoint — Tags: , , — kctnpblog @ 1:56 am

This script will associate one of the out of the box Disposition Approval workflows to a list.
This code requires the SharePoint Powershell Profile to be loaded beforehand

#Include the additional dll references required
[Void] [System.Reflection.Assembly]:: LoadWithPartialName("System")
[Void] [System.Reflection.Assembly]:: LoadWithPartialName("Microsoft.SharePoint.Workflow")

#open the web
$web=Get-SPWeb -webUrl "http://moss";

#list to which the workflow is to be associated

#create workflow association object
$culture=new-object System.Globalization.CultureInfo("en-AU");
$basetemplate = $web.WorkflowTemplates.GetTemplateByName("Disposition Approval",$culture);
$wftasklist=$web.Lists["Workflow Tasks"];
$wfhistorylist=$web.Lists["Workflow History"];
$wfAssoc=[Microsoft.SharePoint.Workflow.SPWorkflowAssociation]:: CreateListAssociation($basetemplate,"Disposition Approval",$wftasklist,$wfhistorylist);

#associate workflow to list

#cleanup and end


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Create a free website or blog at

%d bloggers like this: