Update tell-quote.ps1 and write-quote.ps1

This commit is contained in:
Markus Fleschutz 2022-12-02 09:24:38 +01:00
parent 6400207cf9
commit c8a94f67d6
2 changed files with 8 additions and 9 deletions

View File

@ -16,8 +16,8 @@ try {
$Generator = New-Object System.Random $Generator = New-Object System.Random
$Index = [int]$Generator.next(0, $Table.Count - 1) $Index = [int]$Generator.next(0, $Table.Count - 1)
$Quote = $Table[$Index].Quote $Quote = $Table[$Index].QUOTE
$Author = $Table[$Index].Author $Author = $Table[$Index].AUTHOR
& "$PSScriptRoot/speak-english.ps1" "$Quote (by $Author)" & "$PSScriptRoot/speak-english.ps1" "$Quote (by $Author)"
exit 0 # success exit 0 # success

View File

@ -1,6 +1,6 @@
<# <#
.SYNOPSIS .SYNOPSIS
Writes a random quote to the console Writes a quote to the console
.DESCRIPTION .DESCRIPTION
This PowerShell script writes a random quote to the console. This PowerShell script writes a random quote to the console.
.EXAMPLE .EXAMPLE
@ -12,19 +12,18 @@
#> #>
try { try {
$Table = import-csv "$PSScriptRoot/../Data/quotes.csv" $Table = Import-CSV "$PSScriptRoot/../Data/quotes.csv"
$Generator = New-Object System.Random $Generator = New-Object System.Random
$Index = [int]$Generator.next(0, $Table.Count - 1) $Index = [int]$Generator.next(0, $Table.Count - 1)
$Quote = $Table[$Index].Quote $Quote = $Table[$Index].QUOTE
$Author = $Table[$Index].Author $Author = $Table[$Index].AUTHOR
"" ""
write-host '“'$Quote' ”' Write-Host '“'$Quote' ”'
$Spaces = " " $Spaces = " "
$Spaces = $Spaces.Substring(0, $Quote.Length - $Author.Length) $Spaces = $Spaces.Substring(0, $Quote.Length - $Author.Length)
"$Spaces $($Author.toUpper())" "$Spaces $($Author.toUpper())"
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"