Closed vbondzio closed 4 years ago
Hello Valentin,
There are two mutually exclusive parameters at position 2 (see also: Help Join
):
-On
(possibly together with -Equals
)-OnExpression
These two properties will be automatically recognized by the value type as -On
is a String[]
and -OnExpression
is a ScriptBlock
, both parameters determine which object at the left side will be joined with the object on the right side.
The -Property
parameter, on the other hand, is a named property, meaning that you can't define the value without supplying it's name. The -Property
parameter has a complete different function, it defines the properties of the output object. It is comparable with | Select-Object VendorName, DeviceName, (...)
with the exception that you can refer back to the current $Left
and $Right
objects. e.g. To return the VendorName, DeviceName and concat the VID of the left and right object, you might do something like: -Property VendorName, DeviceName, @{VID = {$Left.$_ + '/' + $Right.$_}}
.
Bottom line, you probably want to do this:
$hostNumaInfo | InnerJoin-Object $hostPciInfo {$Left.PciId -Contains $Right.Id} `
| LeftJoin-Object $hostNicList {$Left.Id -Contains $Right.PCIDevice} `
| LeftJoin-Object $hostHbaList -OnExpression {$Left.Id -Contains $Right.PCIID} `
| Select-Object VendorName, DeviceName,
(...)
I swear I actually read the help... re-reading it, I don't understand how I could misinterpreted it as much as I did. Thank you for the way nicer than necessary explanation!
No problem, note that you get more extensive help (including parameter positions) with Help Join
than Join -?
(or just reading it from the script).
Hi iRon7,
sorry for the blast but as far as I understand, the following examples shouldn't behave differently:
Doesn't work:
Works:
When using "-Property", it seems to join to the first objects even though it doesn't match ...
Granted, it's late and I didn't spend much time on it, feel free to tell me to sod off :-)
Cheers,
Valentin