{"record":{"id":"388bd8a381baf77b","repo":"PowerShell/PowerShell","slug":"this-command-cannot-be-used-because-the-parameter-388bd8","errorCode":null,"errorMessage":"This command cannot be used because the parameter matches multiple properties on the ResourceURI.Check the input parameters and run your command.","messagePattern":"This command cannot be used because the parameter matches multiple properties on the ResourceURI\\.Check the input parameters and run your command\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.WSMan.Management/WsManHelper.cs","lineNumber":441,"sourceCode":"                    if (valueset != null)\n                    {\n                        foreach (DictionaryEntry entry in valueset)\n                        {\n                            xpathString = @\"/*/*[local-name()=\"\"\" + entry.Key + @\"\"\"]\";\n                            if (entry.Key.ToString().Equals(\"location\", StringComparison.OrdinalIgnoreCase))\n                            {\n                                // 'Ignore cim:Location\n                                xpathString = @\"/*/*[local-name()=\"\"\" + entry.Key + @\"\"\" and namespace-uri() != \"\"\" + NS_CIMBASE + @\"\"\"]\";\n                            }\n\n                            XmlNodeList nodes = xmlfile.SelectNodes(xpathString);\n                            if (nodes.Count == 0)\n                            {\n                                throw new ArgumentException(_resourceMgr.GetString(\"NoResourceMatch\"));\n                            }\n                            else if (nodes.Count > 1)\n                            {\n                                throw new ArgumentException(_resourceMgr.GetString(\"MultipleResourceMatch\"));\n                            }\n                            else\n                            {\n                                XmlNode node = nodes[0];\n                                if (node.HasChildNodes)\n                                {\n                                    if (node.ChildNodes.Count > 1)\n                                    {\n                                        throw new ArgumentException(_resourceMgr.GetString(\"NOAttributeMatch\"));\n                                    }\n                                    else\n                                    {\n                                        XmlNode tmpNode = node.ChildNodes[0]; //.Item[0];\n                                        if (!tmpNode.NodeType.ToString().Equals(\"text\", StringComparison.OrdinalIgnoreCase))\n                                        {\n                                            throw new ArgumentException(_resourceMgr.GetString(\"NOAttributeMatch\"));\n                                        }\n                                    }","sourceCodeStart":423,"sourceCodeEnd":459,"githubUrl":"https://github.com/PowerShell/PowerShell/blob/3ff3c711bf54a18f8440f3c5190c3ac91cdc5852/src/Microsoft.WSMan.Management/WsManHelper.cs#L423-L459","documentation":"Thrown during ValueSet processing when a hashtable key matches multiple XML elements in the resource document. The XPath `/*/*[local-name()=\"<key>\"]` returns more than one node, making the target ambiguous — the method cannot determine which element to update.","triggerScenarios":"Passing a -ValueSet key whose local-name matches multiple sibling elements in the resource XML. The SelectNodes count exceeds 1, triggering the MultipleResourceMatch error.","commonSituations":"Resources with repeated elements (e.g., arrays or lists); namespace collisions where elements with the same local name exist under different namespaces; CIM classes with inherited properties that shadow base-class elements.","solutions":["Inspect the resource XML to understand why multiple elements share the same local-name.","Use a more specific ResourceURI that narrows the scope to a single resource instance.","If updating an array element, use the resource-specific API or direct XML manipulation rather than ValueSet."],"exampleFix":"# before\nSet-WSManInstance -ResourceUri 'winrm/config/listener' -ValueSet @{ Address = '*' }\n# → multiple listeners match 'Address'\n\n# after\nSet-WSManInstance -ResourceUri 'winrm/config/listener?Index=0' -ValueSet @{ Address = '*' }","handlingStrategy":"validation","validationCode":"// Before calling Set-WSManInstance, verify each ValueSet key matches exactly one node\nforeach (var key in valueset.Keys)\n{\n    string xpath = $\"/*/*[local-name()=\\\"{key}\\\"]\";\n    XmlNodeList nodes = xmlfile.SelectNodes(xpath);\n    if (nodes.Count > 1)\n    {\n        throw new ArgumentException($\"Property '{key}' matches {nodes.Count} nodes — ambiguous. Use a more specific ResourceURI.\");\n    }\n}","typeGuard":null,"tryCatchPattern":"try { Set-WSManInstance -ResourceUri $uri -ValueSet $values }\ncatch [System.ArgumentException] {\n    if ($_.Exception.Message -match 'multiple') { Write-Warning \"Ambiguous property match. Add a selector to ResourceURI (e.g., ?Index=0) to disambiguate.\" }\n    else { throw }\n}","preventionTips":["Use a more specific ResourceURI with selectors (e.g., 'winrm/config/listener?Index=0') to avoid multi-match.","Inspect the resource XML to identify properties that appear multiple times before including them in ValueSet.","For array-type properties, target a specific instance rather than the parent collection."],"tags":["wsman","valueset","resource-uri","xml","ambiguity","xpath"],"backgroundTag":null,"analyzedSha":"3ff3c711bf54a18f8440f3c5190c3ac91cdc5852","analyzedAt":"2026-08-13T10:39:10.759Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}