Skip to content

Instantly share code, notes, and snippets.

@steviecoaster
Created August 19, 2019 21:14
Show Gist options
  • Select an option

  • Save steviecoaster/0aa95ba792a8067c7db329b9b398fb20 to your computer and use it in GitHub Desktop.

Select an option

Save steviecoaster/0aa95ba792a8067c7db329b9b398fb20 to your computer and use it in GitHub Desktop.
Because dad jokes are always fun.
function Get-DadJoke {
[cmdletBinding()]
Param()
process {
$header = @{
Accept = "application/json"
}
$joke = Invoke-RestMethod -Uri "https://icanhazdadjoke.com/" -Method Get -Headers $header
$joke.joke
}
}
@lukebarone
Copy link

Update for those who cannot read (you know, accessibility stuff)

Add-Type -AssemblyName System.Speech
function Speak-DadJoke {
    [cmdletBinding()]
    Param()

    process {
        $headers = @{
            Accept = "application/json"
        }
        $DJ = Invoke-RestMethod -Uri "https://icanhazdadjoke.com/" -Method Get -Headers $headers
        $Speaker = New-Object System.Speech.Synthesis.SpeechSynthesizer
        $Speaker.Speak($DJ.joke)
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment