当前位置:主页 > Office办公 > PowerShell启动工作流

PowerShell启动工作流

SharePoint PowerShell 启动工作流
SharePoint PowerShell 启动工作流

最近,有个需求,就是需要批量更新列表内容,平时这些操作,都用powershell去完成,但是,powershell需要在服务器上操作,而服务器权限需要通过客户的层层把关,所以,这次就考虑不用命令了,而改用SharePoint网站工作流,然后,用powershell命令去创建任务计划。  这样,以后有需求修改,直接在客户端就能做了,而任务计划,是始终不会变的。  1.创建网站工作流,这个就比较简单了,我们就不多少了,直接在SharePoint Designer里干就好了;  2.启动网站工作流的PowerShell代码段,这个显然是本文的重中之重; 复制代码 # SharePoint.Workflow.Start-SPSiteWorkflowparam ( [string]$Url = "http://sharepoint/demos/workflow", [string]$Workflow = "Sample Site Workflow" )Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")# 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." }

278 次浏览