Skip to content

Write-Quote

Writes a random quote

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

	$randomNumberGenerator = New-Object System.Random
	$row = [int]$randomNumberGenerator.next(0, $table.Count - 1)
	$quote = $table[$row].QUOTE
	$author = $table[$row].AUTHOR
	$spaces = "                                                                                                                             "
	$spaces = $spaces.Substring(0, $quote.Length - $author.Length)
	""
	""
	"??????????????????????????????????????????????????????????"
	"??????????????????????????????????????????????????????????"
	"??????????????????????????????????????????????????????????"
	"??????????????????????????????????????????????????????????"
	"??????????????????????????????????????????????????????????"
	"??????????????????????????????????????????????????????????"
	"??????????????????????????????????????????????????????????"
	"??????????????????????????????????????????????????????????"
	"??????????????????????????????????????????????????????????"
	"??????????????????????????????????????????????????????????"
	"??????????????????????????????????????????????????????????"
	"??????????????????????????????????????????????????????????"
	"??????????????????????????????????????????????????????????"
	"??????????????????????????????????????????????????????????"
	"??????????????????????????????????????????????????????????"
	"??????????????????????????????????????????????????????????"
	"??????????????????????????????????????????????????????????"
	"??????????????????????????????????????????????????????????"
	"??????????????????????????????????????????????????????????"
	"??????????????????????????????????????????????????????????"
	"??????????????????????????????????????????????????????????"
	"??????????????????????????????????????????????????????????"
	""
	""
	Write-Host ""'?'"$quote"'?'"" -foregroundColor Green
	Write-Host "$spaces- $author" -foregroundColor Blue
	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.