PowerShell/Scripts/write-saying.ps1
2021-08-05 14:53:40 +02:00

28 lines
522 B
PowerShell
Executable File

<#
.SYNOPSIS
write-saying.ps1
.DESCRIPTION
Writes a random saying to the console.
.EXAMPLE
PS> .\write-saying.ps1
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz
License: CC0
#>
try {
$Table = import-csv "$PSScriptRoot/../Data/sayings.csv"
$Generator = New-Object System.Random
$Index = [int]$Generator.next(0,66)
$Line = $Table[$Index].Saying
"📣 $Line"
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}