Ehy! (that's "hey", spelt wrong).
Ever had a solution that (erroneously) creates additional custom actions on the list item context menu?
I had this problem this week. A Nintex Workflow that I'm importing (via PowerShell) into a site during a provisioning process does just this. Apparently this happens when you have a workflow with the "Enable workflow to start from the item menu" setting enabled, and then you export that workflow and import it into another site.
The issue becomes apparently after you re-import the workflow more than once. Each time the workflow is re-imported (e.g. in my case when a provisioning process updates a site), the a new version of the custom action is added to the lists context menu, but the old one is not removed.
And this is what you end up with...
That doesn't look very good, and what's worse, only one of those custom actions (menu items) works (the most recently added one).
To sort this out, you can use PowerShell or SharePoint Designer to remove the old custom actions. Since I'm working on a provisioning processing, I used PowerShell to remove the context menu items.
I wrote the PowerShell as a function I could call from another script in my provisioning process. The PowerShell uses the client object model (CSOM), so that it doesn't need to be run on the SharePoint server.
Here it is!
And you can call it from another script like this (in this example, a script located in the same directory):