#requires -version 2.0 # ----------------------------------------------------------------------------- # Script: BarOrder.ps1 # Version: 1.0 # Author: Jeffery Hicks # http://jdhitsolutions.com/blog # http://twitter.com/JeffHicks # Date: 3/14/2011 # Keywords: # Comments: # # "Those who forget to script are doomed to repeat their work." # # **************************************************************** # * DO NOT USE IN A PRODUCTION ENVIRONMENT UNTIL YOU HAVE TESTED * # * THOROUGHLY IN A LAB ENVIRONMENT. USE AT YOUR OWN RISK. IF * # * YOU DO NOT UNDERSTAND WHAT THIS SCRIPT DOES OR HOW IT WORKS, * # * DO NOT USE IT OUTSIDE OF A SECURE, TEST SETTING. * # **************************************************************** # ----------------------------------------------------------------------------- #define an array of beverage choices $drinks=@( "beer","Guiness","milk", "rootbeer","whiskey", "water","wine cooler", "porter","ale","hard lemonade", "chablis","shot") #get two random elements from the array $choice=$drinks | get-random -count 2 #choice is also an array. I'll make my drink order the first element $mydrink=$choice[0] #my friend get's the second element. $yourdrink=$choice[1] #construct a string message using the -f operator $msg="I'll take another {0} and a nice {1} for my friend." -f $mydrink,$yourdrink #display the message Write-Host $msg -ForegroundColor Green #optionally speak it $Voice=New-Object -ComObject "SAPI.SPVoice" $voice.speak($msg) | out-Null