Is there a way to get a list of all suspended workflows in SharePoint 2013 using powershell? i have quite few workflows running in sharepoint 2013 farm and i need to get a list of all suspended instances
Please try the below code from Using SharePoint 2013 Workflow Services JS API. You may have to tweak it according to your requirement.
(function () {
// Getting client context and loading the current web
var context = SP.ClientContext.get_current();
var web = context.get_web();
context.load(web);
// Workflow Services API entry point – WorkflowServiceManager object
var servicesManager = SP.WorkflowServices.WorkflowServicesManager.newObject(context, web);
context.load(servicesManager);
var workflowDefinitions = servicesManager.getWorkflowDeploymentService().enumerateDefinitions(false);
context.load(workflowDefinitions);
context.executeQueryAsync(function (sender, args) {
// enumerateDefinition returns ClientCollection object
var definitionsEnum = workflowDefinitions.getEnumerator();
var empty = true;
console.log(‘Site ‘ + web.get_url() + ‘:’);
// Going through the definitions
while (definitionsEnum.moveNext()) {
var def = definitionsEnum.get_current();
// Displaying information about this definition – DisplayName and Id
console.log(def.get_displayName() + ” (id: ” + def.get_id() + “)”);
empty = false;
}
if (empty) {
console.log(‘No 2013 workflows found.’);
}
}, errFunc);
// Error handling
function errFunc(sender, args) {
alert(“Error occured! ” + args.get_message());
};
})();