Advertisement
Cogger

Get-Excuses.sp1

Mar 30th, 2023
831
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $ExcuseArray   = New-Object System.Collections.ArrayList
  2. $url = "https://gist.githubusercontent.com/Chromulent/eb05e076a5ce097e1e15184f5688856e/raw/675f20603fb3cf44475c437e311ec2fbde7bf4fb/Ballard-Excuses.txt"
  3. $ExcuseContent = (Invoke-WebRequest -Uri $url).Content
  4. $ExcuseCollection = $ExcuseContent.Split([System.Environment]::NewLine,[System.StringSplitOptions]::RemoveEmptyEntries)
  5. $ExcuseCollection | ForEach { $ExcuseArray.Add("$_") > $null }
  6. $ExcuseTotal = $ExcuseArray.Count
  7. $Tab = [char]9
  8. Add-Type -AssemblyName System.Speech
  9. $speak = New-Object System.Speech.Synthesis.SpeechSynthesizer
  10. $speak.SelectVoice('Microsoft David Desktop')
  11.  
  12. $v = 0;
  13. if ($v -ge 0 ){
  14.     $rNum = Get-Random -Minimum 2 -Maximum $ExcuseTotal
  15.     Clear-Host
  16.     $Excuse = $ExcuseArray[$rNum]
  17.     Write-Host("Excuse: " + $Tab + $Excuse ) -ForegroundColor Yellow
  18.     $speak.Speak("$Excuse")
  19.     Start-Sleep -Seconds 15
  20. }
  21.  
  22. $snickers = $True ; Do {
  23.  $Cont = Read-Host -Prompt "Do you want another excuse:  ? [Y/N]"
  24.     switch ($Cont) {
  25.         {($_ -eq "y") -or ($_ -eq "yes") -or ($_ -eq "Y")  -or ($_ -eq "Yes")} {
  26.             $v++;
  27.             $rNum = Get-Random -Minimum 2 -Maximum $ExcuseTotal
  28.             Clear-Host
  29.             $Excuse = $ExcuseArray[$rNum]
  30.             Write-Host("Excuse: " + $Tab + $Excuse ) -ForegroundColor Yellow
  31.             $speak.Speak("$Excuse")
  32.             Start-Sleep -Seconds 15
  33.             Clear-Host ; break}
  34.         {($_ -eq "n") -or ($_ -eq "N")   -or ($_ -eq "no") -or ($_ -eq "No")}  { $snickers = $False; break}
  35.         default {break}
  36.     }
  37. }
  38. Until ($snickers -eq $False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement