Skip to content

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

@d-miles

Description

@d-miles

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions