문제

I have made a Powershell script to run workflow on SharePoint 2010. The workflow manager assignment is the only part of the script with a null value.

$listName = "Action Tracking System"
$Site = Get-SPsite "https://intranet.xxx.xxx.xxx/depts/FSO" | GEt-SPweb
$List = $Site[1].lists[$listname]
$manager = $site[1].workflowmanager
$Association  = $list.WorkflowAssociations[5]    #30 Day Reminder workflow
$association.AllowAsyncManualStart = $true
$association.AllowManual = $true

$data = $Association.AssociationData
foreach ($Item in $list.Items)
{
    Write-Host "    Content: " $Item.Name
    $wf = $manager.StartWorkflow($Item,$association,$data)
}
$manager.Dispose()

It returns you cannot call a method on a null value expression (char 27).

The site is a subsite of FSO, the $site[1] index shows the correct site. How can I start this workflow?

도움이 되었습니까?

해결책

The code is wrong. The following is what you need to start a SharePoint 2010 workflow.

$ListName = 'Action Tracking System';
$WorkflowName = '30 Day Reminder';

$Web = Get-SPWeb 'https://intranet.xxx.xxx.xxx/depts/FSO';
$List = $Web.Lists[$Listname];
$Items = $List.GetItems();

$Manager = $Web.Site.WorkflowManager;
$Association = $List.WorkflowAssociations.GetAssociationByName($WorkflowName, 'en-US');
$Data = $Association.AssociationData;

foreach ($Item in $Items)
{
    Write-Host 'Content: ' $Item.Name;
    $WF = $Manager.StartWorkflow($Item, $Association, $Data, $true);
}

$Manager.Dispose();
$Web.Dispose();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top