Select #vBeersRaleigh Location with PowerShell
Now that I'm working hard to get vBeers started in Raleigh I've started a little list of good places the group should meet. The trick is that there are so many good places to go there is some value in mixing up the meeting location. Naturally I turn to PowerShell and the Get-Random cmdlet.
Here's a list of locations saved to a file C:\Josh\beer.txt
Big Boss Brewery
Natty Greene's
LoneRider Brewery
Tyler's Taproom
CBC Brewery
Aviator Breweries
Bull city Burger
Full Steam
Durham Bulls
First we need to import the list from the file with Get-Content
   $beer = Get-Content "C:\Josh\beer.txt"
Typing in $beer will give you the list of locations. Now you just need to pipe that to Get-Random to get your random selection.
If I follow this then the next location would be:
  Full Steam Brewery in Durham
Even though I had a small sample set of data guaranteeing I'll have duplicates from time to time I found it did pretty well. I tested Get-Random by first sorting the list alphabetically:
typing $beer gave me the alphabetical list (I love PowerShell by the way)
I ran the following repeatedly to see how often a back to back duplicates would show up.
  $beer | Sort-Object | Get-Random
Out of a quick sample of 16 times nearly all were selected at least once with Full Steam being selected 3 times. Poor Bull City Burger didn't get selected at all.
While the decision for the next #vBeersRaleigh really hasn't been made yet it was fun to write that up because I'm definitely going to use it at home for "What's for dinner tonight?"