Cannot bind argument to parameter '...'
Cannot bind argument to parameter '...'
DodaTech
3 min read
The “Cannot bind argument to parameter ‘…’” error means the value cannot be converted to the parameter type, or the pipeline input lacks the required property.
What It Means
PowerShell cmdlet parameters are strongly typed — each parameter expects a specific .NET type like String, Int32, DateTime, or IPAddress. When you pass a value that cannot be implicitly converted (e.g., a string like “hello” for a [int] parameter), PowerShell raises a binding error. The same happens when piping objects: if the cmdlet expects a property named Name but your object has FullName, the parameter cannot bind.
Why It Happens
- You passed a string where a number is required:
Get-Process -Id "abc". - You passed a string where a
DateTimeis required:Get-Date -Date "not-a-date". - Pipeline objects do not have the expected property name.
- You are using the wrong parameter set — the parameter exists but not in the current combination.
- The value is
$nulland the parameter does not accept nulls. - The value is an array but the parameter expects a single value.
How to Fix It
1. Check the expected parameter type
# See the parameter types
Get-Command Get-Process -Syntax
(Get-Command Get-Process).Parameters["Id"].ParameterType2. Cast values to the correct type explicitly
# Bad — string where int is expected
Get-Process -Id "123"
# Good — explicit cast
Get-Process -Id [int]"123"3. Specify the correct property name in the pipeline
# Create objects with the property names the cmdlet expects
$objects = [PSCustomObject]@{
Name = "notepad"
Id = 1234
}
$objects | Get-Process # Works because 'Name' and 'Id' match parameters4. Use Select-Object to rename properties before piping
Get-Service |
Select-Object @{Name="Name"; Expression={$_.ServiceName}} |
Get-Process5. Check for $null values
$processName = $null
Get-Process -Name $processName # Binding error
# Guard against null
if ($processName) {
Get-Process -Name $processName
}6. Use splatting for complex parameter sets
$params = @{
ComputerName = "Server01"
Credential = Get-Credential
ErrorAction = "Stop"
}
Invoke-Command @params -ScriptBlock { Get-Service } Previous
Cannot assign value of type '...' to type '...'
Next
ERROR 1040 (HY000): Too many connections
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro