# PSDiscord – PowerShell Module

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.

pages

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.

[View images (3)](#pf-content-image-1-0)

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](https://github.com/gngrninja/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.

## 💡 Note worthy features

- Send feature rich notifications to **Discord**
- Fairly easy to use
- No license needed. Free to use.
- Open source
- Cross-plaform (Win/Linux/Mac)
- PowerShell 5.1 or Higher

### 💡 Useful links

- Code is published on [GitHub](https://github.com/EvotecIT/PSDiscord)
- Issues should be reported on [GitHub](https://github.com/EvotecIT/PSDiscord/issues)
- Code is published as a module on [PowerShellGallery](https://www.powershellgallery.com/packages/PSDiscord/)

### 💡 How can I use it?

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.

```powershell
$Uri = 'https://discordapp.com/api/webhooks/5083323013'

$Author = New-DiscordAuthor -Name 'PSBlacklistChecker' -IconUrl "https://raw.githubusercontent.com/EvotecIT/PSTeams/master/Links/Asset 130.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 130.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 130.png"
```

[!\[Discord webhook message generated by PSDiscord with sections, facts, thumbnail, and branding.\](/wp-content/uploads/2019/01/img_5c3089ad7e553.png)](/wp-content/uploads/2019/01/img_5c3089ad7e553.png)

You can also use **CreateConfig** switch will save **URI** for later use so you can skip it in subsequent uses.

```powershell
$Uri = '...'
Send-DiscordMessage -WebHookUrl $Uri -Text 'Test' -CreateConfig
```

[!\[PSDiscord example saving webhook configuration with CreateConfig for later reuse.\](/wp-content/uploads/2019/01/img_5c308f228b883.png)](/wp-content/uploads/2019/01/img_5c308f228b883.png)

```powershell
Send-DiscordMessage -Text 'Test' -AvatarName 'My Test'
```

[!\[Simple Discord message sent by PSDiscord using only text and a custom avatar name.\](/wp-content/uploads/2019/01/img_5c308f5763ba0.png)](/wp-content/uploads/2019/01/img_5c308f5763ba0.png)

There's also switch **TextToSpeach** which basically tells discord to say to you the name of **Avatar** and the text included in **Text** field.

```powershell
Send-DiscordMessage -Text 'Test' -AvatarName 'My Test' -TextToSpeech
```

### 💡 How to install and update?

Since **PSDiscord** is published on [PowerShellGallery](https://www.powershellgallery.com/packages/PSDiscord/) it's quite easy to install it with just one little command

```powershell
Install-Module PSDiscord
```

When you want to update this module… just use

```powershell
Update-Module PSDiscord
```

### 💡 Quick fixes / helpful tips

- [PowerShellGallery – You are installing modules from an untrusted repository](https://evotec.xyz/powershellgallery-you-are-installing-modules-from-an-untrusted-repository/)
- [Install-Module: The term Install-Module is not recognized as the name of cmdlet, function, script file or operable program](https://evotec.xyz/install-module-the-term-install-module-is-not-recognized-as-the-name-of-cmdlet-function-script-file-or-operable-program/)

<!-- PowerForge markdown source sha256:1BD432ED504147D10C20194C7248BE7F1911E4608CE3BF8CF063D215E09C41C7; title=True -->

<!-- PowerForge markdown artifact sha256:B8B3E34595C4C9F863A9A6DCCAFBEB4A992D836460FACA7D17DF27918DCFBC12 -->
