This PowerShell module allows sending notifications to Discord. It's pretty easy to use, and kind of brother to PSTeams module using related cmdlets. It's cross-platform and works on Windows, Linux, and MacOS. While there is already excellent Discord module PSDsHook it used classes and was giving me some errors that I just had no way to fix. This Discord module is straightforward and is relatively easy to use.
Following code can send a message to Discord. It changes Author of the message, adds an image as thumbnail and picture at the same time. It also turns the avatar name and logo.
$Uri = 'https://discordapp.com/api/webhooks/5083323013' $Author = New-DiscordAuthor -Name 'PSBlacklistChecker' -IconUrl "https://raw.githubusercontent.com/EvotecIT/PSTeams/master/Links/Asset%20130.png" $Fact = New-DiscordFact -Name 'Blacklisted IP 89.74.48.97' -Value 'Found on blacklist dnsbl.sorbs.net' -Inline $false $Thumbnail = New-DiscordThumbnail -Url "https://raw.githubusercontent.com/EvotecIT/PSTeams/master/Links/Asset%20130.png" $Section = New-DiscordSection -Title 'Everybody panic!' -Description '' -Facts $Fact, $Fact, $Fact -Color BlueViolet -Author $Author -Thumbnail $Thumbnail -Image $Thumbnail Send-DiscordMessage -WebHookUrl $Uri -Sections $Section -AvatarName 'PSBlackListChecker' -AvatarUrl "https://raw.githubusercontent.com/EvotecIT/PSTeams/master/Links/Asset%20130.png"
You can also use CreateConfig switch will save URI for later use so you can skip it in subsequent uses.
$Uri = '...' Send-DiscordMessage -WebHookUrl $Uri -Text 'Test' -CreateConfig
Send-DiscordMessage -Text 'Test' -AvatarName 'My Test'
There's also switch TextToSpeach which basically tells discord to say to you the name of Avatar and the text included in Text field.
Send-DiscordMessage -Text 'Test' -AvatarName 'My Test' -TextToSpeech
Since PSDiscord is published on PowerShellGallery it's quite easy to install it with just one little command
Install-Module PSDiscord
When you want to update this module… just use
Update-Module PSDiscord