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

Find-SlackMessage's Raw switch doesn't work #125

Open
d-miles opened this issue Sep 6, 2022 · 0 comments
Open

Find-SlackMessage's Raw switch doesn't work #125

d-miles opened this issue Sep 6, 2022 · 0 comments

Comments

@d-miles
Copy link

d-miles commented Sep 6, 2022

The -Raw switch on Find-SlackMessage doesn't work because of the following lines of code in Find-SlackMessage.ps1 (110-111):

if($Raw)
{
    $link = "$($Script:PSSlack.ArchiveUri)/$($response.channel)/p$($response.ts -replace '\.')"
    $response | Add-Member -MemberType NoteProperty -Name link -Value $link
    $response
}

That's because this link property is always added to the $response object on lines 98-99:

$link = "$($Script:PSSlack.ArchiveUri)/$($response.channel)/p$($response.ts -replace '\.')"
$response | Add-Member -MemberType NoteProperty -Name link -Value $link

This seems to have been introduced in a change from May 16, 2016, but it's unclear if the intent was to remove addition of the link property from lines 98-99. Since the link property has been set for over 6 years now, it seems to be clear that it works anyway -- just that using the Raw switch produces an error because the link property already exists:

Cannot add a member with the name "link" because a member with that name already exists. To overwrite the member anyway, add the Force parameter to your command.
At line:10 char:5
+     Invoke-Command -ComputerName ... -Credential ... -S ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (@{ok=True; quer...ges=; link=//p}:PSObject) [Add-Member], InvalidOperationException
    + FullyQualifiedErrorId : MemberAlreadyExists,Microsoft.PowerShell.Commands.AddMemberCommand
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

1 participant