Skip to content

Instantly share code, notes, and snippets.

@SQLDBAWithABeard
Last active July 13, 2025 22:37
Show Gist options
  • Select an option

  • Save SQLDBAWithABeard/3fb42ad44987be7cbb4c5dba6cc65620 to your computer and use it in GitHub Desktop.

Select an option

Save SQLDBAWithABeard/3fb42ad44987be7cbb4c5dba6cc65620 to your computer and use it in GitHub Desktop.
insult generator
I am serious. And don't call me Shirley.
function Get-Insult {
[CmdletBinding()]
param (
[Parameter()]
[switch]$Speak = $true
)
Add-Type -AssemblyName System.Speech
$synth = New-Object System.Speech.Synthesis.SpeechSynthesizer
$voice = $synth.GetInstalledVoices().VoiceInfo.Name
$synth.SelectVoice($voice[0])
$uri = 'https://insult.mattbas.org/api/insult'
try {
$response = Invoke-RestMethod -Uri $uri -Method Get
$response
} catch {
# Write-Error "Failed to retrieve insult: $_"
# Optionally, you can return a default message or handle the error differently
return "I couldn't think of an insult right now."
}
if($Speak) {
$synth.Speak($response)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment