Showing posts from April, 2013

Powershell To Attach workflow on Content Type and create Retention Policy on it - SharePoint 2013

Hi Friends, I got a requirement to create retention policy on Content type and action is to start workflow. as well attach workflow to the content type. I choose to go with powershell. save the following code into file called SetupRetentionPolicy.ps1 call like: c:\>.\SetupRetentionPolicy.ps1 -url <weburl> -ContentTypeName <Contenttype> param( $url=$null, $ContentTypeName=$null) $site = get-spsite $url $web = $site.openweb() Enable-SPFeature –identity "LocationBasedPolicy" -URL $url -ErrorAction SilentlyContinue $Property = "Modified" $Period = 1; $PeriodType = "years" function AddWorkflowToContentType($site, $ctName, $WfName, $WfAssociationName, $TaxTaskList) { [void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SharePoint') [void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.Office.Policy') [Guid]$wfTemplateId = New-Object Gui