Skip to content

Tell-Joke

Tells a random joke by text-to-speech

try {
	$table = Import-CSV "$PSScriptRoot/data/jokes.csv"

	$randomNumberGenerator = New-Object System.Random
	$row = [int]$randomNumberGenerator.next(0, $table.count - 1)

	& "$PSScriptRoot/speak-english.ps1" $table[$row].Joke
	exit 0 # success
} catch {
	"?? ERROR: $($Error[0]) (script line $($_.InvocationInfo.ScriptLineNumber))"
	exit 1
}

This script has no configurable parameters.

An interactive directory of PowerShell scripts.