PowerShell: cannot bind a parameter
Documentation: Microsoft Learn
Check argument types, parameter sets and pipeline input when PowerShell cannot bind a parameter.
What it means
PowerShell could not bind an argument to the target command. The value may have an incompatible type, the supplied parameters may belong to different parameter sets, or a parameter name may be ambiguous. Inspect the error record to identify the failing argument.
Likely causes
- A string was passed where the parameter wants an object, such as a name where an ADUser instance is required
- Two parameters from mutually exclusive parameter sets were supplied together
- An incoming pipeline object has no property matching a parameter that accepts ValueFromPipelineByPropertyName
- An array reached a parameter that accepts only one value
- A parameter name was abbreviated to a prefix that matches more than one parameter
Check
Run these checks before changing anything.
Fix
Reduce the call to a valid minimal set, then add optional arguments one at a time. For pipeline binding, capture the incoming objects and inspect them separately with Get-Member; inserting Get-Member directly before the destination changes the pipeline to member-description objects. Use Trace-Command for binding diagnostics when the minimal case remains unclear.
Verify: Run a valid call and the relevant invalid boundary case. Confirm the intended parameter set and output shape.