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)


I am not sure what the problem is. Help is much appreciated. Thank you.

1 Answer 1


I finally realised the error message was because my admin account did not have enough rights to run the script. I've been told the clue was the "unauthorized operation..." part of the error message. When I logged in as the farm account, it worker perfectly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.