What's the best way to go about writing a PowerShell command to activate a workflow for each item in a list?

There's a million articles out there and I'm wondering what the best way is.


Not sure if it's the best way, but it will do the trick.

$web = Get-SPWeb "Url to web";    
$manager = $web.Site.WorkFlowManager;    
$list = $web.Lists["your list"];

$assoc = $list.WorkflowAssociations.GetAssociationByName("Workflow Name","culture string"); # culture string like en-US

$view = $list.Views["Your view name"]; #All Items

$items = $list.GetItems($view);    
$data = $assoc.AssociationData;

foreach ($item in $items) { $wf = $manager.StartWorkFlow($item,$assoc,$data,$true); }
| improve this answer | |
  • I am getting this error when I try to run this script: Get-SPWeb : Cannot find an SPSite object that contains the following Id or Url: http://portaldev.com/sites/it. – PT_C Oct 13 '15 at 16:17
  • Try Get-SPWeb Identity "" – allegro octopus Mar 22 '19 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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