Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors When AddKey Parameter Contains a Space #16

Closed
franklesniak opened this issue Sep 3, 2021 · 5 comments
Closed

Errors When AddKey Parameter Contains a Space #16

franklesniak opened this issue Sep 3, 2021 · 5 comments

Comments

@franklesniak
Copy link

Hi There,

I've noticed that when I run Join-Object and specify the -AddKey parameter with a space, e.g.:

$CSVInterimResult = Join-Object -Left @($hashtableWMPInventoryComputers.Values) -Right @($hashtableSophosComputers.Values) -LeftJoinProperty 'Computer Name' -RightJoinProperty 'Name' -Type 'AllInBoth' -AddKey 'Computer Name' -ExcludeLeftProperties 'Computer Name' -ExcludeRightProperties 'Name'

I get errors:

Exception calling "Create" with "1" argument(s): "At line:11 char:31
+             $RowMain.Computer Name = $Key
+                               ~~~~
Unexpected token 'Name' in expression or statement."
At C:\Program Files\WindowsPowerShell\Modules\Join-Object\2.0.2\Join-Object.ps1:772 char:9
+         [System.Func[System.Object, [Collections.Generic.IEnumerable[ ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ParseException

Join-Object : Cannot find an overload for "FullGroupJoin" and the argument count: "6".
At line:1 char:21
+ ... rimResult = Join-Object -Left @($hashtableWMPInventoryComputers.Value ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Join-Object], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest,Join-Object

On the other hand, if I run this same command without the space in the parameter, e.g.,:

$CSVInterimResult = Join-Object -Left @($hashtableWMPInventoryComputers.Values) -Right @($hashtableSophosComputers.Values) -LeftJoinProperty 'Computer Name' -RightJoinProperty 'Name' -Type 'AllInBoth' -AddKey 'ComputerName' -ExcludeLeftProperties 'Computer Name' -ExcludeRightProperties 'Name'

This works just fine.

@ili101
Copy link
Owner

ili101 commented Sep 3, 2021

I think I found it can you try this fix 9d5a29a in Join-Object.ps1?
I will release a fixed version later.

@franklesniak
Copy link
Author

franklesniak commented Sep 4, 2021

That seems to have fixed it. Thanks for digging into this so quickly! I tested on PS 5.1 on WS2016.

@ili101
Copy link
Owner

ili101 commented Apr 2, 2022

I have changed the fix:

# from
$RowMain.'YourKey'
# to
$RowMain.$AddKey

# DataTable 
# from
$RowMain['YourKey']
# to
$RowMain[$AddKey]

So it will work with things like a 'a"a

@ili101
Copy link
Owner

ili101 commented Apr 5, 2022

Released to gallery. please reopen if you find any issue

@ili101 ili101 closed this as completed Apr 5, 2022
@franklesniak
Copy link
Author

Awesome, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants