SCSM Orchestrator Error: An item with the same key has already been added
I recently ran into an issue with the Service Manager integration pack for Orchestrator, not returning object in a particular class. In my class it happened to be the Service Request class, but as I discovered this same problem could happen to any class. When a runbook would execute I would receive the error message, “An item with the same key has already been added.” Also, when I went into the Get-Object activity in Orchestrator I would only see the “SC Object Guid” as an available property.
It turns out this problem is caused when two entries on an enumeration list have the same internal name value. This can happen if you use one of the external Enum Builder solutions, or just edit the XLM yourself. To find the rogue enum entry I wrote a PowerShell script that you can use to query a class in Service Manager, find every enumeration list for the class and all classes it inherits, and checks if it contains any duplicate values, and outputs the results.
To run the script, you just need to specify the display name of the class and your management server name. The display name should match the name listed in the Orchestrator activity.
The script will output the results from each enumeration list.
Once you identify the duplicate entry, all you have to do is export the management pack, change the internal name of one of the duplicates, and import the updated management pack back into Service Manager. Then if you run the script again, it should come back with no duplicates.
After that, the Orchestrator activities should start working again.