diff --git a/Scripts/write-joke.ps1 b/Scripts/write-joke.ps1 index ef3e1e1f..09bc296e 100755 --- a/Scripts/write-joke.ps1 +++ b/Scripts/write-joke.ps1 @@ -1,11 +1,11 @@ <# .SYNOPSIS - Writes a random Juck Norris joke to the console + Writes a random joke .DESCRIPTION - This PowerShell script writes a random Juck Norris joke to the console. + This PowerShell script selects a random joke from Data/jokes.csv and writes it to the console. .EXAMPLE - PS> ./write-joke - When Chuck Norris does division, there are no remainders. 😂 + PS> ./write-joke.ps1 + Chuck Norris can dribble a bowling ball. 😂 .LINK https://github.com/fleschutz/PowerShell .NOTES @@ -13,13 +13,13 @@ #> try { - $Table = import-csv "$PSScriptRoot/../Data/jokes.csv" + $table = Import-CSV "$PSScriptRoot/../Data/jokes.csv" - $Generator = New-Object System.Random - $Index = [int]$Generator.next(0, $Table.Count - 1) - $Joke = $Table[$Index].Joke + $randomNumberGenerator = New-Object System.Random + $row = [int]$randomNumberGenerator.next(0, $table.Count - 1) + $joke = $table[$row].JOKE - "$Joke 😂" + Write-Host "`n$Joke 😂" -foregroundColor Magenta exit 0 # success } catch { "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" diff --git a/Scripts/write-quote.ps1 b/Scripts/write-quote.ps1 index c449bc91..a3e7879e 100755 --- a/Scripts/write-quote.ps1 +++ b/Scripts/write-quote.ps1 @@ -1,8 +1,8 @@ <# .SYNOPSIS - Writes a quote + Writes a random quote .DESCRIPTION - This PowerShell script selects a random quote and prints it to the console. + This PowerShell script selects a random quote from Data/quotes.csv and writes it to the console. .EXAMPLE PS> ./write-quote.ps1 “ We must become the change we want to see. „ @@ -23,7 +23,7 @@ try { $spaces = " " $spaces = $spaces.Substring(0, $quote.Length - $author.Length) - Write-Host "`n"'“'"$quote"'„'"`n$spaces- $author" + Write-Host "`n"'“'"$quote"'„'"`n$spaces- $author" -foregroundColor Magenta exit 0 # success } catch { "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"