PSSlack
PSSlack copied to clipboard
Deleting messages from private channel
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?
I guess the support for OAuth App Credentials might be required, because the credentials of the bot have the proper access rights.
#3
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.