PSSlack icon indicating copy to clipboard operation
PSSlack copied to clipboard

Deleting messages from private channel

Open MovGP0 opened this issue 7 years ago • 2 comments

I have a private channel with an misbehaving bot that filled up the messages. I tried the following:

$token = 'xoxp-.......';
get-slackchannel -token $token -name "privatechannelname" | Get-SlackHistory -Count 1000 | Remove-SlackMessage

unfortunately, this only works with public channels. Is there any way to delete messages from a private channel?

MovGP0 avatar Oct 05 '18 13:10 MovGP0

I guess the support for OAuth App Credentials might be required, because the credentials of the bot have the proper access rights.

#3

MovGP0 avatar Oct 05 '18 13:10 MovGP0

It seems that when deleting from private channels you need to specify the ChannelID and not the Channel name. The piplined input contains only the channel name. The Remove-SlackMessage help file shows adding in channel ID info for such a situation:

Get-SlackChannel -name "TargetChannel" |
                Get-SlackHistory -Count 1000 |
                Where-Object Username -match "MalfunctioningBot" |
                Remove-SlackMessage -ChannelID "C5H8XBUMV"

However, that doesn't seem to be currently working. I made a fix here https://github.com/RamblingCookieMonster/PSSlack/pull/104 that I believe addresses the issue and will allow you to specify a ChannelID for Remove-SlackMessage.

PaulJordan avatar Jan 12 '20 21:01 PaulJordan