<# .SYNOPSIS Tells a joke by text-to-speech .DESCRIPTION This script selects a random Chuck Norris joke in Data/jokes.csv and speaks it by text-to-speech (TTS). .EXAMPLE PS> ./tell-joke .NOTES Author: Markus Fleschutz · License: CC0 .LINK https://github.com/fleschutz/PowerShell #> try { $Table = import-csv "$PSScriptRoot/../Data/jokes.csv" $Generator = New-Object System.Random $Index = [int]$Generator.next(0, $Table.Count - 1) $Reply = $Table[$Index].Joke & "$PSScriptRoot/give-reply.ps1" "$Reply" exit 0 # success } catch { "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" exit 1 }