PowerShell/PowerShell · error · ArgumentException
This command cannot be used because the parameter matches mu
Error message
This command cannot be used because the parameter matches multiple properties on the ResourceURI.Check the input parameters and run your command.
What it means
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.
Source
Thrown at src/Microsoft.WSMan.Management/WsManHelper.cs:441
if (valueset != null)
{
foreach (DictionaryEntry entry in valueset)
{
xpathString = @"/*/*[local-name()=""" + entry.Key + @"""]";
if (entry.Key.ToString().Equals("location", StringComparison.OrdinalIgnoreCase))
{
// 'Ignore cim:Location
xpathString = @"/*/*[local-name()=""" + entry.Key + @""" and namespace-uri() != """ + NS_CIMBASE + @"""]";
}
XmlNodeList nodes = xmlfile.SelectNodes(xpathString);
if (nodes.Count == 0)
{
throw new ArgumentException(_resourceMgr.GetString("NoResourceMatch"));
}
else if (nodes.Count > 1)
{
throw new ArgumentException(_resourceMgr.GetString("MultipleResourceMatch"));
}
else
{
XmlNode node = nodes[0];
if (node.HasChildNodes)
{
if (node.ChildNodes.Count > 1)
{
throw new ArgumentException(_resourceMgr.GetString("NOAttributeMatch"));
}
else
{
XmlNode tmpNode = node.ChildNodes[0]; //.Item[0];
if (!tmpNode.NodeType.ToString().Equals("text", StringComparison.OrdinalIgnoreCase))
{
throw new ArgumentException(_resourceMgr.GetString("NOAttributeMatch"));
}
}View on GitHub (pinned to 3ff3c711bf)
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.
Example fix
# before
Set-WSManInstance -ResourceUri 'winrm/config/listener' -ValueSet @{ Address = '*' }
# → multiple listeners match 'Address'
# after
Set-WSManInstance -ResourceUri 'winrm/config/listener?Index=0' -ValueSet @{ Address = '*' } Defensive patterns
Strategy: validation
Validate before calling
// Before calling Set-WSManInstance, verify each ValueSet key matches exactly one node
foreach (var key in valueset.Keys)
{
string xpath = $"/*/*[local-name()=\"{key}\"]";
XmlNodeList nodes = xmlfile.SelectNodes(xpath);
if (nodes.Count > 1)
{
throw new ArgumentException($"Property '{key}' matches {nodes.Count} nodes — ambiguous. Use a more specific ResourceURI.");
}
} Try / catch
try { Set-WSManInstance -ResourceUri $uri -ValueSet $values }
catch [System.ArgumentException] {
if ($_.Exception.Message -match 'multiple') { Write-Warning "Ambiguous property match. Add a selector to ResourceURI (e.g., ?Index=0) to disambiguate." }
else { throw }
} Prevention
- 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.
When it happens
Trigger: Passing a -ValueSet key whose local-name matches multiple sibling elements in the resource XML. The SelectNodes count exceeds 1, triggering the MultipleResourceMatch error.
Common situations: 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.
Related errors
- This command cannot be used because the parameter does not m
- Node is not present in the XML, Please give valid XPath
- This command cannot be used because the parameter matches a
- A {0} cannot be specified when {1} is specified.
- Event cannot be written because multiple events with id {0}
AI-assisted analysis of PowerShell/PowerShell@3ff3c711bf (2026-08-13).
Data as JSON: /api/errors/388bd8a381baf77b.
Report an issue: GitHub.