I am very new to powershell. I am trying to use it to start a (send Document Set to repository) workflow on selected Document Sets in a library. The workflow worked when I used it manually on one document set at a time, but when I ran the script, I came across this error:
*
Exception calling "StartWorkflow" with "4" argument(s): "Attempted to perform a unauthorized operation." At line:3 char:32 + $wf=$manager.StartWorkflow <<<< ($item,$assoc,$data,$true) + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorID : DotNetMethodException*
# URL of the Site
$weburl = "myURL"
$web = Get-SPWeb $weburl
$manager = $web.Site.WorkFlowManager
# Name of the list
$list = $web.Lists["Style"]
# Name of the Workflow
$assoc = $list.WorkflowAssociations| where {$_.Name -eq "copyStyleToSomewhere"}
$data = $assoc.AssociationData
$listItems = $list.Items
foreach($item in $listItems){
if($item.Name -match "style1234"){
$wf = $manager.StartWorkFlow($item,$assoc,$data,$true)
}
}
$manager.Dispose()
$web.Dispose()
I am not sure what the problem is. Help is much appreciated. Thank you.