mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-09 01:38:26 +02:00
Update tell-quote.ps1 and write-quote.ps1
This commit is contained in:
parent
6400207cf9
commit
c8a94f67d6
@ -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
|
||||||
|
@ -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])"
|
||||||
|
Loading…
Reference in New Issue
Block a user