{"id":4099,"date":"2014-10-10T10:32:03","date_gmt":"2014-10-10T14:32:03","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=4099"},"modified":"2014-10-30T17:15:33","modified_gmt":"2014-10-30T21:15:33","slug":"friday-fun-take-a-chance-with-powershell","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4099\/friday-fun-take-a-chance-with-powershell\/","title":{"rendered":"Friday Fun &#8211; Take a Chance with PowerShell"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/101014_1431_FridayFunTa1.jpg\" alt=\"\" width=\"134\" height=\"188\" align=\"left\" \/>Last week I showed you my <a href=\"http:\/\/jdhitsolutions.com\/blog\/2014\/10\/friday-fun-lets-play-a-game\/\">PowerShell Bingo<\/a> game. While the game itself might be a fun way to pass the time, the real goal was to teach you some PowerShell techniques and concepts without you realizing it. This week, I thought I'd keep with the gaming theme and take up chance. Specifically let's roll some dice and flip some coins. These aren't especially complicated tasks in PowerShell, and it is hard to say what problem they might solve, but let's have some fun anyway.<\/p>\n<p>First up, flipping coins.<\/p>\n<p>Flipping a coin is essentially a True\/False game. Or another way to look at is Even\/Odd. My favorite way is to use the modulo operator.<\/p>\n<pre class=\"&quot;lang:batch\" decode:true=\"\">PS C:\\&gt; 5%2\r\n1\r\nPS C:\\&gt; 6%2\r\n0\r\n<\/pre>\n<p>Those values can be represented as Booleans.<\/p>\n<pre class=\"lang:batch decode:true\">PS C:\\&gt; 5%2 -as [boolean]\r\nTrue\r\nPS C:\\&gt; 6%2 -as [boolean]\r\nFalse\r\n<\/pre>\n<p>So all I need is a random number and perform a modulo operation. Here's the function I created.<\/p>\n<pre class=\"lang:ps decode:true\">Function Invoke-CoinToss {\r\n\r\n[cmdletbinding(DefaultParameterSetName=\"_AllParameterSets\")]\r\nParam(\r\n[Parameter(ParameterSetName=\"Boolean\")]\r\n[switch]$AsBoolean,\r\n[Parameter(ParameterSetName=\"EvenOdd\")]\r\n[switch]$EvenOdd\r\n)\r\n\r\nWrite-Verbose \"Using parameter set $($PSCmdlet.ParameterSetName)\"\r\n\r\n#get a random number between 1 and 100 to test\r\n$i = Get-Random -Minimum 1 -Maximum 100\r\nWrite-Verbose \"Random result = $i\"\r\n\r\n#use the modulo operator\r\nif ($i%2) {\r\n    Write-Verbose \"Odd\/Heads\/True\"\r\n    Switch ($PSCmdlet.ParameterSetName) {\r\n     \"Boolean\" { $True}\r\n     \"EvenOdd\" {\"Odd\" }\r\n     Default {\"Heads\"}\r\n    } #switch\r\n} #if\r\nelse {\r\n    Write-Verbose \"Even\/Tails\/False\"\r\n    Switch ($PSCmdlet.ParameterSetName) {\r\n     \"Boolean\" { $False}\r\n     \"EvenOdd\" {\"Even\" }\r\n     Default {\"Tails\"}\r\n    } #switch\r\n} #else\r\n\r\n} #end Invoke-CoinToss\r\n<\/pre>\n<p>I used a valid verb but will also define a more user-friendly alias.<\/p>\n<pre class=\"lang:ps decode:true\">Set-Alias -Name Flip-Coin -Value Invoke-CoinToss\r\n<\/pre>\n<p>Because you may want several different types of output, not necessarily the best idea for a function but this might be an exception. And remember this is supposed to be educational not necessarily practical. My function uses parameter sets and depending on the set, decides what type of result to write to the pipeline.<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/101014_1431_FridayFunTa2.png\" alt=\"\" \/><\/p>\n<p>And it seems to work pretty well.<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/101014_1431_FridayFunTa3.png\" alt=\"\" \/><\/p>\n<p>Next, let's roll some dice. Again I'll use Get-Random . A single dice roll is as simple as this:<\/p>\n<pre class=\"\" lang:ps=\"\" decode:true=\"\">get-random -Minimum 1 -Maximum 7\r\n<\/pre>\n<p>To roll multiple dice, you could do this:<\/p>\n<pre class=\"\" lang:ps=\"\" decode:true=\"\">$Dice = 4\r\n1..$Dice | foreach {\r\n Get-Random -Minimum 1 -Maximum 7\r\n }\r\n<\/pre>\n<p>Naturally I wrote a function with a few more bells and whistles because I like shiny toys.<\/p>\n<pre class=\"lang:ps decode:true\">Function Invoke-Dice {\r\n\r\n[cmdletbinding()]\r\nParam(\r\n[ValidateRange(1,10)]\r\n[int]$Dice = 2,\r\n[ValidateRange(6,12)]\r\n[int]$Sides = 6,\r\n[Alias(\"Total\")]\r\n[switch]$Sum\r\n)\r\n\r\nWrite-Verbose \"Rolling $dice $sides-sided dice\"\r\n\r\n#generate a list of all possible numbers then select all random numbers at once\r\n$result = (1..$Sides)*$Dice | Get-Random -Count $Dice\r\n\r\nif ($sum) {\r\n    write-Verbose \"Totaling the result\"\r\n    Write-Verbose $($result -join \",\")\r\n    ($result | Measure-Object -sum).Sum\r\n}\r\nelse {\r\n    $result\r\n}\r\n\r\n} #end roll-dice\r\n\r\nSet-Alias -name Roll-Dice -value Invoke-Dice\r\n<\/pre>\n<p>This function lets you choose the number of dice to roll. Notice I use a ValidateRange attribute to limit the number of dice. And in case you are rolling for a game of Dungeons and Dragons which has some extra-sided dice, I gave you that option as well.<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/101014_1431_FridayFunTa4.png\" alt=\"\" \/><\/p>\n<p>In some games, you need the total so I added that as well. One thing that I changed was my rolling technique. In this version I am pre-generating an array of all possible values and then get the specified number of random values.<\/p>\n<pre class=\"lang:ps decode:true\">$result = (1..$Sides)*$Dice | Get-Random -Count $Dice\r\n<\/pre>\n<p>Not that it is super critical, but this technique is faster.<\/p>\n<pre class=\"lang:ps decode:true \">$dice = 8\r\n$sides = 7\r\n Measure-Command {\r\n  1..$Dice | foreach {\r\n  Get-Random -Minimum 1 -Maximum ($sides+1)\r\n  }\r\n }\r\n\r\n Measure-Command {\r\n  (1..$Sides)*$Dice | Get-Random -Count $Dice\r\n }\r\n<\/pre>\n<p>Here's the result<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/101014_1431_FridayFunTa5.png\" alt=\"\" \/><\/p>\n<p>If you are debating between different techniques in a script or function, use Measure-Command to see how they perform.<\/p>\n<p>Now you have some tools to build your own PowerShell games and maybe learn something new in the process. If you do, I hope you'll share. Enjoy!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last week I showed you my PowerShell Bingo game. While the game itself might be a fun way to pass the time, the real goal was to teach you some PowerShell techniques and concepts without you realizing it. This week, I thought I&#8217;d keep with the gaming theme and take up chance. Specifically let&#8217;s roll&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"New Friday Fun - Take a Chance with #PowerShell","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[271,4],"tags":[568,245,534,540],"class_list":["post-4099","post","type-post","status-publish","format-standard","hentry","category-friday-fun","category-powershell","tag-friday-fun","tag-get-random","tag-powershell","tag-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Friday Fun - Take a Chance with PowerShell &#8226; The Lonely Administrator<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/4099\/friday-fun-take-a-chance-with-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Friday Fun - Take a Chance with PowerShell &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"Last week I showed you my PowerShell Bingo game. While the game itself might be a fun way to pass the time, the real goal was to teach you some PowerShell techniques and concepts without you realizing it. This week, I thought I&#039;d keep with the gaming theme and take up chance. Specifically let&#039;s roll...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/4099\/friday-fun-take-a-chance-with-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2014-10-10T14:32:03+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-10-30T21:15:33+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/101014_1431_FridayFunTa1.jpg\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4099\\\/friday-fun-take-a-chance-with-powershell\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4099\\\/friday-fun-take-a-chance-with-powershell\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Friday Fun &#8211; Take a Chance with PowerShell\",\"datePublished\":\"2014-10-10T14:32:03+00:00\",\"dateModified\":\"2014-10-30T21:15:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4099\\\/friday-fun-take-a-chance-with-powershell\\\/\"},\"wordCount\":426,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4099\\\/friday-fun-take-a-chance-with-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/10\\\/101014_1431_FridayFunTa1.jpg\",\"keywords\":[\"Friday Fun\",\"Get-Random\",\"PowerShell\",\"Scripting\"],\"articleSection\":[\"Friday Fun\",\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4099\\\/friday-fun-take-a-chance-with-powershell\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4099\\\/friday-fun-take-a-chance-with-powershell\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4099\\\/friday-fun-take-a-chance-with-powershell\\\/\",\"name\":\"Friday Fun - Take a Chance with PowerShell &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4099\\\/friday-fun-take-a-chance-with-powershell\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4099\\\/friday-fun-take-a-chance-with-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/10\\\/101014_1431_FridayFunTa1.jpg\",\"datePublished\":\"2014-10-10T14:32:03+00:00\",\"dateModified\":\"2014-10-30T21:15:33+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4099\\\/friday-fun-take-a-chance-with-powershell\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4099\\\/friday-fun-take-a-chance-with-powershell\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4099\\\/friday-fun-take-a-chance-with-powershell\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/10\\\/101014_1431_FridayFunTa1.jpg\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/10\\\/101014_1431_FridayFunTa1.jpg\",\"width\":134,\"height\":188},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4099\\\/friday-fun-take-a-chance-with-powershell\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Friday Fun\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/friday-fun\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Friday Fun &#8211; Take a Chance with PowerShell\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Friday Fun - Take a Chance with PowerShell &#8226; The Lonely Administrator","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4099\/friday-fun-take-a-chance-with-powershell\/","og_locale":"en_US","og_type":"article","og_title":"Friday Fun - Take a Chance with PowerShell &#8226; The Lonely Administrator","og_description":"Last week I showed you my PowerShell Bingo game. While the game itself might be a fun way to pass the time, the real goal was to teach you some PowerShell techniques and concepts without you realizing it. This week, I thought I'd keep with the gaming theme and take up chance. Specifically let's roll...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4099\/friday-fun-take-a-chance-with-powershell\/","og_site_name":"The Lonely Administrator","article_published_time":"2014-10-10T14:32:03+00:00","article_modified_time":"2014-10-30T21:15:33+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/101014_1431_FridayFunTa1.jpg","type":"","width":"","height":""}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4099\/friday-fun-take-a-chance-with-powershell\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4099\/friday-fun-take-a-chance-with-powershell\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Friday Fun &#8211; Take a Chance with PowerShell","datePublished":"2014-10-10T14:32:03+00:00","dateModified":"2014-10-30T21:15:33+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4099\/friday-fun-take-a-chance-with-powershell\/"},"wordCount":426,"commentCount":4,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4099\/friday-fun-take-a-chance-with-powershell\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/101014_1431_FridayFunTa1.jpg","keywords":["Friday Fun","Get-Random","PowerShell","Scripting"],"articleSection":["Friday Fun","PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/4099\/friday-fun-take-a-chance-with-powershell\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4099\/friday-fun-take-a-chance-with-powershell\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4099\/friday-fun-take-a-chance-with-powershell\/","name":"Friday Fun - Take a Chance with PowerShell &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4099\/friday-fun-take-a-chance-with-powershell\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4099\/friday-fun-take-a-chance-with-powershell\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/101014_1431_FridayFunTa1.jpg","datePublished":"2014-10-10T14:32:03+00:00","dateModified":"2014-10-30T21:15:33+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4099\/friday-fun-take-a-chance-with-powershell\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/4099\/friday-fun-take-a-chance-with-powershell\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4099\/friday-fun-take-a-chance-with-powershell\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/101014_1431_FridayFunTa1.jpg","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/10\/101014_1431_FridayFunTa1.jpg","width":134,"height":188},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4099\/friday-fun-take-a-chance-with-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Friday Fun","item":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},{"@type":"ListItem","position":2,"name":"Friday Fun &#8211; Take a Chance with PowerShell"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":1554,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1554\/friday-fun-powershell-powerball-numbers\/","url_meta":{"origin":4099,"position":0},"title":"Friday Fun PowerShell PowerBall Numbers","author":"Jeffery Hicks","date":"July 8, 2011","format":false,"excerpt":"Like many of you, I dream about hitting the lottery and retiring to live the good life. Unfortunately I rarely play so I guess my odds are winning are pretty slim. But for the latest installment of Friday Fun, I thought I would have PowerShell help me pick some numbers\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1389,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1389\/friday-fun-randomness-abounds\/","url_meta":{"origin":4099,"position":1},"title":"Friday Fun Randomness Abounds","author":"Jeffery Hicks","date":"April 29, 2011","format":false,"excerpt":"I find it a little ironic that although I like efficiency, structure and order I'm fascinated with randomness. In today's Friday Fun I want to explore a few ways you might incorporate randomness into your PowerShell scripting. Perhaps you need a random number between 100 and 500. Or a string\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1136,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1136\/friday-fun-snappy-shortcuts\/","url_meta":{"origin":4099,"position":2},"title":"Friday Fun &#8211; Snappy Shortcuts","author":"Jeffery Hicks","date":"February 11, 2011","format":false,"excerpt":"In one of my recent Prof. PowerShell columns, I wrote about using the Wscript.Shell VBScript object in PowerShell to retrieve special folder paths. Another handy trick is the ability to create shortcut links to either file or web resources. Let me show you how to accomplish this in PowerShell and\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/02\/create-shortcuts-300x185.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":2787,"url":"https:\/\/jdhitsolutions.com\/blog\/friday-fun\/2787\/friday-fun-a-graphical-powershell-history-picker\/","url_meta":{"origin":4099,"position":3},"title":"Friday Fun A Graphical PowerShell History Picker","author":"Jeffery Hicks","date":"February 8, 2013","format":false,"excerpt":"One of my favorite features in PowerShell 3.0 is that you can select items in Out-Gridview which will then pipe the object back to the pipeline. One way I've been using this is as graphical \"picker\" for command history. I use Get-History, actually its alias h, all the time. Once\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"history-picker","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/02\/history-picker-300x230.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":3925,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3925\/friday-fun-reverse-powershell\/","url_meta":{"origin":4099,"position":4},"title":"Friday Fun Reverse PowerShell","author":"Jeffery Hicks","date":"July 18, 2014","format":false,"excerpt":"These Friday Fun posts are not supposed to be practical, yet hopefully still entertaining and educational. Today's article is no exception but I 'll be you'll try it at least once. And you'll maybe even learn something about PowerShell that perhaps you didn't know before. It all starts with a\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"reverse","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/07\/reverse.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":6240,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6240\/friday-fun-with-timely-powershell-prompts\/","url_meta":{"origin":4099,"position":5},"title":"Friday Fun with Timely PowerShell Prompts","author":"Jeffery Hicks","date":"November 30, 2018","format":false,"excerpt":"If PowerShell is a part of your daily routine, you most likely have a console window open all day. In addition to using PowerShell to get stuff done, you can use PowerShell to keep you on track. I've written before and talked about how I use PowerShell to manage my\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/image_thumb-13.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/image_thumb-13.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/image_thumb-13.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/11\/image_thumb-13.png?resize=700%2C400&ssl=1 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4099","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=4099"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4099\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=4099"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=4099"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=4099"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}