I try and run this Script using Powershell ISC run as Admin:
#Site URL
$web = Get-SPWeb "http://cgprojects/sites/tfs";
$web.AllowUnsafeUpdates = $true;
#List Name
$list = $web.Lists["Project Initiation"];
# Iterate through all Items in List and all Workflows on Items.
foreach ($item in $list.Items) {
foreach ($wf in $item.Workflows) {
#Cancel Workflows
[Microsoft.SharePoint.Workflow.SPWorkflowManager]::CancelWorkflow($wf);
}
}
$web.Dispose()
What I get is this result:
The term 'Get-SPWeb' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:2 char:18 + $web = Get-SPWeb <<<< "http:// "; + CategoryInfo : ObjectNotFound: (Get-SPWeb:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException Property 'AllowUnsafeUpdates' cannot be found on this object; make sure it exists and is settable. At line:3 char:7 + $web. <<<< AllowUnsafeUpdates = $true;
+ CategoryInfo : InvalidOperation: (AllowUnsafeUpdates:String) [], RuntimeException + FullyQualifiedErrorId : PropertyNotFound Cannot index into a null array. At line:6 char:21 + $list = $web.Lists[ <<<< "Project Initiation"]; + CategoryInfo : InvalidOperation: (Project Initiation:String) [], RuntimeException + FullyQualifiedErrorId : NullArray Unable to find type [Microsoft.SharePoint.Workflow.SPWorkflowManager]: make sure that the assembly containing this type is loaded. At line:13 char:51 + [Microsoft.SharePoint.Workflow.SPWorkflowManager] <<<< ::CancelWorkflow($wf);
+ CategoryInfo : InvalidOperation: (Microsoft.Share...WorkflowManager:String) [], RuntimeException + FullyQualifiedErrorId : TypeNotFound You cannot call a method on a null-valued expression. At line:16 char:14 + $web.Dispose <<<< () + CategoryInfo : InvalidOperation: (Dispose:String) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull