Error defining PSDscRunAsCredential Parameter in DSC Configuration

less than 1 minute read

Scenario

The following error was occurring whilst testing a DSC Configuration:

At line:1 char:15
+ Configuration Test {
+               ~~~~
ConfigurationStatementToken: System.ArgumentException: An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)   at System.Management.Automation.Language.Parser.ConfigurationStatementRule(IEnumerable`1 customAttributes, Token configurationToken)

PSDscRunAsCredential Error

Solution

Do NOT add a parameter called PSDscRunAsCredential to a DSC Configuration

The error message made a bit more sense once I realised PSDscRunAsCredential should not be used as a parameter name, but it would be more obvious if the PSDscRunAsCredential parameter itself was underlined.