{"id":4287,"date":"2015-03-14T09:26:43","date_gmt":"2015-03-14T13:26:43","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=4287"},"modified":"2015-03-13T18:48:23","modified_gmt":"2015-03-13T22:48:23","slug":"pi-in-the-sky","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4287\/pi-in-the-sky\/","title":{"rendered":"Pi in the Sky"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/03\/031315_2058_PiintheSky1.gif\" alt=\"\" width=\"109\" height=\"130\" \/>In celebration of Pi day, I thought I'd post some quick and dirty PowerShell code you can use to calculate pi. I found some easy to follow explanations at <a href=\"http:\/\/www.wikihow.com\/Calculate-Pi\" target=\"_blank\">http:\/\/www.wikihow.com\/Calculate-Pi<\/a> that weren't too difficult to transform into PowerShell code. And you might even learn something new about PowerShell along the way.<\/p>\n<p>Before we begin, I hope you know that you can always get the value using the [Math] class:<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/03\/031315_2058_PiintheSky2.png\" alt=\"\" \/><\/p>\n<p>But where's the fun in that? First up is my PowerShell version of Gregory-Leibniz series. This works by deriving pi from an infinite series.<\/p>\n<p><strong><em>\u03c0 = (4\/1) - (4\/3) + (4\/5) - (4\/7) + (4\/9) - (4\/11) + (4\/13) - (4\/15)\u2026<br \/>\n<\/em><\/strong><\/p>\n<p>Seems simple enough. I need a large range of odd-numbered denominators. Then I need to alternately add and subtract. I'm going to need a loop and I can use the modulo operator (%) to test each time through the loop. If I am on an even number I'll add, otherwise I subtract. Here's what I came up with.<\/p>\n<pre class=\"lang:ps decode:true \">#total number of denominators to use\r\n$total = 10000\r\n$a = 1\r\n$d=@($a)\r\n#build array of odd numbers\r\ndo {\r\n$a+=2\r\n$d+=$a\r\n} until ($d.count -ge $total)\r\n\r\n$pi = 0\r\nfor ($i=0;$i -lt $d.count;$i++) {\r\nif ($i%2) {\r\n$pi-= 4\/$d[$i]\r\n}\r\nelse {\r\n$pi+= 4\/$d[$i]\r\n}\r\n}\r\n$pi\r\n<\/pre>\n<p>This takes a little bit of time but it works.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/03\/031315_2058_PiintheSky3.png\" alt=\"\" \/><\/p>\n<p>Then I thought I'd try the Nilakantha series.<\/p>\n<p><strong><em>\u03c0 = 3 + 4\/(2*3*4) - 4\/(4*5*6) + 4\/(6*7*8) - 4\/(8*9*10) + 4\/(10*11*12) - 4\/(12*13*14) ...<\/em><\/strong><\/p>\n<p>Some of the principals are the same. The tricky part here is looping through the collection of numbers and grouping them.<\/p>\n<pre class=\"lang:ps decode:true \">$n=2..10000\r\n$pi = 3\r\n#need a counter to to know whether to add or subtract\r\n$tick = 0\r\n#loop through the numbers\r\nfor ($i=0;$i -lt $n.count-1;$i+=2) {\r\nif ($tick%2) {\r\n$pi-= 4\/($n[$i] * $n[$i+1] * $n[$i+2])\r\n}\r\nelse {\r\n$pi+= 4\/($n[$i] * $n[$i+1] * $n[$i+2])\r\n}\r\n$tick++\r\n}\r\n$pi<\/pre>\n<p>This is noticeably faster and more accurate, well as far as you can be calculating an irrational number.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/03\/031315_2058_PiintheSky4.png\" alt=\"\" \/><\/p>\n<p>And the last way is using an Arcsine Function\/Inverse Sine Function:<\/p>\n<p><strong><em>pi = 2 * (Arcsin(sqrt(1 - x^2))) + abs(Arcsin(x))<\/em><\/strong><\/p>\n<p>This gets a little tricky in PowerShell but it can be accomplished with the [Math] class. You have to watch out for the parentheses.<\/p>\n<pre class=\"lang:ps decode:true \">$x = 0.987654\r\n$pi = 2 * (([math]::Asin([math]::Sqrt(1-([math]::Pow($x,2))))) + [math]::Abs([math]::Asin($x)))<\/pre>\n<p>The value of $x is between -1 and 1.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/03\/031315_2058_PiintheSky5.png\" alt=\"\" \/><\/p>\n<p>Also pretty quick, albeit a bit harder on the eyes to read.<\/p>\n<p>Now if you'll excuse me I have some circles that need to be measured.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In celebration of Pi day, I thought I&#8217;d post some quick and dirty PowerShell code you can use to calculate pi. I found some easy to follow explanations at http:\/\/www.wikihow.com\/Calculate-Pi that weren&#8217;t too difficult to transform into PowerShell code. And you might even learn something new about PowerShell along the way. Before we begin, I&#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":"Special for today: Pi in the Sky with #PowerShell #PiDay2015","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":[4],"tags":[347,534,540],"class_list":["post-4287","post","type-post","status-publish","format-standard","hentry","category-powershell","tag-math","tag-powershell","tag-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Pi in the Sky &#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\/4287\/pi-in-the-sky\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Pi in the Sky &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"In celebration of Pi day, I thought I&#039;d post some quick and dirty PowerShell code you can use to calculate pi. I found some easy to follow explanations at http:\/\/www.wikihow.com\/Calculate-Pi that weren&#039;t too difficult to transform into PowerShell code. And you might even learn something new about PowerShell along the way. Before we begin, I...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/4287\/pi-in-the-sky\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2015-03-14T13:26:43+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/03\/031315_2058_PiintheSky1.gif\" \/>\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=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4287\\\/pi-in-the-sky\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4287\\\/pi-in-the-sky\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Pi in the Sky\",\"datePublished\":\"2015-03-14T13:26:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4287\\\/pi-in-the-sky\\\/\"},\"wordCount\":308,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4287\\\/pi-in-the-sky\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/03\\\/031315_2058_PiintheSky1.gif\",\"keywords\":[\"math\",\"PowerShell\",\"Scripting\"],\"articleSection\":[\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4287\\\/pi-in-the-sky\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4287\\\/pi-in-the-sky\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4287\\\/pi-in-the-sky\\\/\",\"name\":\"Pi in the Sky &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4287\\\/pi-in-the-sky\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4287\\\/pi-in-the-sky\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/03\\\/031315_2058_PiintheSky1.gif\",\"datePublished\":\"2015-03-14T13:26:43+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4287\\\/pi-in-the-sky\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4287\\\/pi-in-the-sky\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4287\\\/pi-in-the-sky\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/03\\\/031315_2058_PiintheSky1.gif\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/03\\\/031315_2058_PiintheSky1.gif\",\"width\":109,\"height\":130},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4287\\\/pi-in-the-sky\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Pi in the Sky\"}]},{\"@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":"Pi in the Sky &#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\/4287\/pi-in-the-sky\/","og_locale":"en_US","og_type":"article","og_title":"Pi in the Sky &#8226; The Lonely Administrator","og_description":"In celebration of Pi day, I thought I'd post some quick and dirty PowerShell code you can use to calculate pi. I found some easy to follow explanations at http:\/\/www.wikihow.com\/Calculate-Pi that weren't too difficult to transform into PowerShell code. And you might even learn something new about PowerShell along the way. Before we begin, I...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4287\/pi-in-the-sky\/","og_site_name":"The Lonely Administrator","article_published_time":"2015-03-14T13:26:43+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/03\/031315_2058_PiintheSky1.gif","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":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4287\/pi-in-the-sky\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4287\/pi-in-the-sky\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Pi in the Sky","datePublished":"2015-03-14T13:26:43+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4287\/pi-in-the-sky\/"},"wordCount":308,"commentCount":0,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4287\/pi-in-the-sky\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/03\/031315_2058_PiintheSky1.gif","keywords":["math","PowerShell","Scripting"],"articleSection":["PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/4287\/pi-in-the-sky\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4287\/pi-in-the-sky\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4287\/pi-in-the-sky\/","name":"Pi in the Sky &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4287\/pi-in-the-sky\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4287\/pi-in-the-sky\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/03\/031315_2058_PiintheSky1.gif","datePublished":"2015-03-14T13:26:43+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4287\/pi-in-the-sky\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/4287\/pi-in-the-sky\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4287\/pi-in-the-sky\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/03\/031315_2058_PiintheSky1.gif","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/03\/031315_2058_PiintheSky1.gif","width":109,"height":130},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4287\/pi-in-the-sky\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Pi in the Sky"}]},{"@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":3492,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3492\/friday-fun-pi-romania\/","url_meta":{"origin":4287,"position":0},"title":"Friday Fun: Pi-romania","author":"Jeffery Hicks","date":"October 11, 2013","format":false,"excerpt":"I was doing some benchmarks the other day, and one of the tests was a calculation of pi using a particular algorithm. I found that quite interesting and naturally this made me curious if I could do the same calculation in PowerShell. Of course, if all you need is the\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":"http:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/8\/8c\/Matheon2.jpg\/320px-Matheon2.jpg","width":350,"height":200},"classes":[]},{"id":7680,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7680\/friday-fun-back-to-school-with-powershell\/","url_meta":{"origin":4287,"position":1},"title":"Friday Fun: Back to School with PowerShell","author":"Jeffery Hicks","date":"September 11, 2020","format":false,"excerpt":"For today's fun with PowerShell, I thought I'd share my solutions for a recent Iron Scripter challenge. If you aren't familiar with these challenges, and you should be, they are designed to test your PowerShell skills and hopefully help you learn something new. There are challenges for all skill levels\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\/2020\/09\/get-cylindervolume-format.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/09\/get-cylindervolume-format.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/09\/get-cylindervolume-format.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/09\/get-cylindervolume-format.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":2450,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2450\/friday-fun-powershell-crypto\/","url_meta":{"origin":4287,"position":2},"title":"Friday Fun PowerShell Crypto","author":"Jeffery Hicks","date":"July 20, 2012","format":false,"excerpt":"I'm a big fan of codes, ciphers and secret messages. I obviously am a big PowerShell fan as well. So why not mash these things together? Today's Friday Fun is a PowerShell module I call PSCode. The module contains a few functions for encoding and decoding text. Now, before you\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\/2012\/07\/pscode-1-300x101.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":2062,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2062\/export-and-import-hash-tables\/","url_meta":{"origin":4287,"position":3},"title":"Export and Import Hash Tables","author":"Jeffery Hicks","date":"February 2, 2012","format":false,"excerpt":"I use hash tables quite a bit and with the impending arrival of PowerShell 3.0 I expect even more so. PowerShell v3 allows you to define a hash table of default parameter values. I'm not going to to cover that feature specifically, but it made me realize I needed a\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":840,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/840\/pipelines-consoles-and-hosts\/","url_meta":{"origin":4287,"position":4},"title":"Pipelines, Consoles and Hosts","author":"Jeffery Hicks","date":"August 19, 2010","format":false,"excerpt":"I continue to come across a particular topic in discussion forums that causes many PowerShell beginners a lot of headaches and more than a little frustration. I know I've written about this before and I'm sure I'll cover it again, but when writing anything in PowerShell that you see in\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/08\/write-demo.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":633,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/633\/bool-vs-switch\/","url_meta":{"origin":4287,"position":5},"title":"Bool vs Switch","author":"Jeffery Hicks","date":"April 30, 2010","format":false,"excerpt":"I have to say I\u2019m generally impressed with the quality of submissions to this year\u2019s Scripting Games. But there is a recurring concept that some people are using and I think there\u2019s a better way. Some contestants are defining function or script parameters as booleans. But I believe they really\u2026","rel":"","context":"In &quot;Best Practices&quot;","block_context":{"text":"Best Practices","link":"https:\/\/jdhitsolutions.com\/blog\/category\/best-practices\/"},"img":{"alt_text":"test-bool","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/04\/testbool_thumb.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4287","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=4287"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4287\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=4287"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=4287"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=4287"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}