Running SCSM 2012 SP1 UR4 with SMLets Beta 4 installed. Two SCSM PowerShell workflows (created with the Authoring Tool) that trigger upon Service Request creation.
Workflow 1 - PowerShell script modifies the activities contained in the SR.
Workflow 2 - PowerShell script modifies the SR itself.
Intermittently, both workflows will fail. This appears to happen when both workflows execute concurrently.
Outputting the error from both we see:
__$error[0] | Format-List -Force | Out-String__
```
Exception : System.ArgumentException: Item has already been added. Key in dictionary: 'localhost' Key being added: 'localhost' at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add) at SMLets.ConnectionHelper.GetMG(String computerName, PSCredential credential) in c:\Users\Administrator\Documents\WindowsPowerShell\CodePlex\smlets\Main\Source\SMLets\SMLets\Helper.cs:line 301 at SMLets.SMCmdletBase.BeginProcessing() in c:\Users\Administrator\Documents\WindowsPowerShell\CodePlex\smlets\Main\Source\SMLets\SMLets\Helper.cs:line 69
TargetObject : localhost
CategoryInfo : InvalidOperation: (localhost:String) [Get-SCSMClass], ArgumentException
FullyQualifiedErrorId : GenericMessage,SMLets.GetSMClassCommand
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
PipelineIterationInfo : {0, 0}
PSMessageDetails :
```
__$error[0].exception | format-list -force | Out-String__
```
Message : Item has already been added. Key in dictionary: 'localhost' Key being added: 'localhost'
ParamName :
Data : {}
InnerException :
TargetSite : Void Insert(System.Object, System.Object, Boolean)
StackTrace : at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add) at SMLets.ConnectionHelper.GetMG(String computerName, PSCredential credential) in c:\Users\Administrator\Documents\WindowsPowerShell\CodePlex\smlets\Main\Source\SMLets\SMLets\Helper.cs:line 301 at SMLets.SMCmdletBase.BeginProcessing() in c:\Users\Administrator\Documents\WindowsPowerShell\CodePlex\smlets\Main\Source\SMLets\SMLets\Helper.cs:line 69
HelpLink :
Source : mscorlib
```
__$error[0].exception.stacktrace | Out-String__
```
at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
at SMLets.ConnectionHelper.GetMG(String computerName, PSCredential credential) in c:\Users\Administrator\Documents\WindowsPowerShell\CodePlex\smlets\Main\Source\SMLets\SMLets\Helper.cs:line 301
at SMLets.SMCmdletBase.BeginProcessing() in c:\Users\Administrator\Documents\WindowsPowerShell\CodePlex\smlets\Main\Source\SMLets\SMLets\Helper.cs:line 69
```
Comments: ** Comment from web user: psikic **
Workflow 1 - PowerShell script modifies the activities contained in the SR.
Workflow 2 - PowerShell script modifies the SR itself.
Intermittently, both workflows will fail. This appears to happen when both workflows execute concurrently.
Outputting the error from both we see:
__$error[0] | Format-List -Force | Out-String__
```
Exception : System.ArgumentException: Item has already been added. Key in dictionary: 'localhost' Key being added: 'localhost' at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add) at SMLets.ConnectionHelper.GetMG(String computerName, PSCredential credential) in c:\Users\Administrator\Documents\WindowsPowerShell\CodePlex\smlets\Main\Source\SMLets\SMLets\Helper.cs:line 301 at SMLets.SMCmdletBase.BeginProcessing() in c:\Users\Administrator\Documents\WindowsPowerShell\CodePlex\smlets\Main\Source\SMLets\SMLets\Helper.cs:line 69
TargetObject : localhost
CategoryInfo : InvalidOperation: (localhost:String) [Get-SCSMClass], ArgumentException
FullyQualifiedErrorId : GenericMessage,SMLets.GetSMClassCommand
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
PipelineIterationInfo : {0, 0}
PSMessageDetails :
```
__$error[0].exception | format-list -force | Out-String__
```
Message : Item has already been added. Key in dictionary: 'localhost' Key being added: 'localhost'
ParamName :
Data : {}
InnerException :
TargetSite : Void Insert(System.Object, System.Object, Boolean)
StackTrace : at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add) at SMLets.ConnectionHelper.GetMG(String computerName, PSCredential credential) in c:\Users\Administrator\Documents\WindowsPowerShell\CodePlex\smlets\Main\Source\SMLets\SMLets\Helper.cs:line 301 at SMLets.SMCmdletBase.BeginProcessing() in c:\Users\Administrator\Documents\WindowsPowerShell\CodePlex\smlets\Main\Source\SMLets\SMLets\Helper.cs:line 69
HelpLink :
Source : mscorlib
```
__$error[0].exception.stacktrace | Out-String__
```
at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
at SMLets.ConnectionHelper.GetMG(String computerName, PSCredential credential) in c:\Users\Administrator\Documents\WindowsPowerShell\CodePlex\smlets\Main\Source\SMLets\SMLets\Helper.cs:line 301
at SMLets.SMCmdletBase.BeginProcessing() in c:\Users\Administrator\Documents\WindowsPowerShell\CodePlex\smlets\Main\Source\SMLets\SMLets\Helper.cs:line 69
```
Comments: ** Comment from web user: psikic **
We are having this issue too. We are running in Service Management Automation. If we have two runbooks (PowerShell Workflows) that try to connect to a MG at the same time, one of them fails.
Item has already been added. Key in dictionary: '(SCSM Server name)' Key being added:
'(SCSM Server name)'
at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
at SMLets.ConnectionHelper.GetMG(String computerName, PSCredential credential) in c:\Users\Administrator\Documents\WindowsPowerShell\CodePlex\smlets\Main\Source\SMLets\SMLets\Helper.cs:line 301
at SMLets.SMCmdletBase.BeginProcessing() in c:\Users\Administrator\Documents\WindowsPowerShell\CodePlex\smlets\Main\Source\SMLets\SMLets\Helper.cs:line 69