Closed Erikov-K closed 4 years ago
Hello Erikov,
Thanks for your message.
I just uploaded a new version (3.1.3) a few days ago that resolve an issue with the -Where
object and outer joins (e.g. -JoinType Left
), see: CHANGELOG
I am not sure if this resolves your issue but maybe you can test this first. The point is that although I have a lot of regression tests that I walk through before uploading a new version, I do not specifically test the script as a module... Please, let me know if this version resolves the issue.
Some other hints and options:
$Left
and $Right
object in the -where
parameter are not same as the $Left
and $Right
input objects you created (but could be the reason you get different results as a Module vs Script, as they might get into scope within the Join-Script
due to the bug prior 3.1.3).Merge-Object
command: $LeftObject | Merge $RightObject -On {$Left.'lun-serial' -ceq $Right.'lun-serial'}
Hello, iRon7! Thank you for a support! You gave me right advice: I started using 'Join-Object' via dot-sourcing instead of 'import-module' and all worked fine! Thank you very much!
Hello Erikov,
I have uploaded a new version of the Join
cmdlet (3.2.0) which you might like because I have added two new switches for the -On
/-Equals
comparison: -Strict
and -MatchCase
.
This means for your used case, you can now do:
$LeftObject | LeftJoin $RightObject -On lun-serial -MatchCase
(Which will be faster then using expressions).
Note: In this version, I have stricter defined the parameter sets, this means that the -On <ScriptBlock>
is actually changed to" -OnExpression <ScriptBlock>
but you can still use -On <ScriptBlock>
as this -On
is an abbreviation of -OnExpression
which is only excepting a [ScriptBlock]
type.
Hello!
Thank you for you work! Your function help me every day! :-)
I found scenario in which work of function looks strange. When I using ' Import-Module -FullyQualifiedName $PathToModule' for import function 'Join-Object' I find a issue: '-where' condition not work correctly. If I placing your source code of your function directly into my script - all work fine! Version of a 'Join-Object' 3.0.6
Output with 'Import-module':
lun-serial volume vol-state host-DiskNumber host-OperationalStatus
---------- ------ --------- --------------- ----------------------
QvaAo+E56ZNH cl_Cedar_WithAcessPath_SQL_T03_3 online
QvaAo+E56ZNh cl_ExportMasterDB_Max_to_Dell_SQL_T03_2 online
Output with directly function definition:
lun-serial volume vol-state host-DiskNumber host-OperationalStatus
---------- ------ --------- --------------- ----------------------
QvaAo+E56ZNH cl_Cedar_WithAcessPath_SQL_T03_3 online 11 Online
QvaAo+E56ZNh cl_ExportMasterDB_Max_to_Dell_SQL_T03_2 online 34 Offline
Left and right arrays for join you can find below:
$myobj = New-Object -TypeName PSObject
Add-Member -InputObject $myobj -MemberType 'NoteProperty' -Name 'lun-serial' -Value "QvaAo+E56ZNH"
Add-Member -InputObject $myobj -MemberType 'NoteProperty' -Name 'host-DiskNumber' -Value "11"
Add-Member -InputObject $myobj -MemberType 'NoteProperty' -Name 'host-OperationalStatus' -Value "Online"
$Right += $myobj
$myobj = New-Object -TypeName PSObject
Add-Member -InputObject $myobj -MemberType 'NoteProperty' -Name 'lun-serial' -Value "QvaAo+E56ZNh"
Add-Member -InputObject $myobj -MemberType 'NoteProperty' -Name 'host-DiskNumber' -Value "34"
Add-Member -InputObject $myobj -MemberType 'NoteProperty' -Name 'host-OperationalStatus' -Value "Offline"
$Right += $myobj
Result = Join-Object -LeftObject $Left -RightObject $Right -JoinType Left -On lun-serial -where {$Left.'lun-serial' -ceq $Right.'lun-serial'}
$Result | Format-Table`
$Left = @()
$myobj = New-Object -TypeName PSObject
Add-Member -InputObject $myobj -MemberType 'NoteProperty' -Name 'volume' -Value "cl_Cedar_WithAcessPath_SQL_T03_3"
Add-Member -InputObject $myobj -MemberType 'NoteProperty' -Name 'vol-state' -Value "online"
Add-Member -InputObject $myobj -MemberType 'NoteProperty' -Name 'lun-serial' -Value "QvaAo+E56ZNH"
$Left += $myobj
$myobj = New-Object -TypeName PSObject
Add-Member -InputObject $myobj -MemberType 'NoteProperty' -Name 'volume' -Value "cl_ExportMasterDB_Max_to_Dell_SQL_T03_2"
Add-Member -InputObject $myobj -MemberType 'NoteProperty' -Name 'vol-state' -Value "online"
Add-Member -InputObject $myobj -MemberType 'NoteProperty' -Name 'lun-serial' -Value "QvaAo+E56ZNh"
$Left += $myobj
`
$Right = @()