Powershell - Conditionally add parameter/argument to cmdlet
How about using the hashtable approach to creating new objects:
$Object = New-Object PSObject -Property @{ Name = $obj.Name OptValue1 = $obj.OptValue1 OptValue2 = $obj.OptValue2 OptValue3 = $null OptValue4 = "MyValue"} $Object
UpdateSplatting may also help, see here for more details, but if all your parameter names match you might be able to call New-Connection then pass it a hashtable containing your values.
New-Connection @par