I did the following:
$oldWorkflow="MyOldWorkflow";
$oldAssoc=$list.WorkflowAssociations.GetAssociationByName($oldWorkflow,"en-US");
$list.RemoveWorkflowAssociation($oldAssoc);
After that I can see that the workflow does not exist anymore. But on each Item that had the workflow before I receive an error when trying to display the workflows:
Getting Error Message for Exception System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.ArgumentException: Column 'Reservat' doesn't exist
I never had a column with that name. After adding that column manually to the list, the error messages changed to:
Application error when access /_layouts/15/Workflow.aspx, Error=Object reference not set to an instance of an object.
Any chance to solve this mess? (The old workflow does NOT exist anymore as WSP)
UPDATE: I can still find the workflows using Powershell:
foreach ($wf in $item.Workflows)
if ($wf.ParentAssociation.Name -eq $oldWorkflow)
...
But in the same time $list.WorkflowAssociations.GetAssociationByName
does NOT return the workflow
$list.Update()
?