{"id":3492,"date":"2013-10-11T11:41:23","date_gmt":"2013-10-11T15:41:23","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=3492"},"modified":"2013-10-10T15:43:53","modified_gmt":"2013-10-10T19:43:53","slug":"friday-fun-pi-romania","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3492\/friday-fun-pi-romania\/","title":{"rendered":"Friday Fun: Pi-romania"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft\" alt=\"\" src=\"http:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/8\/8c\/Matheon2.jpg\/320px-Matheon2.jpg\" width=\"320\" height=\"212\" \/>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 value of pi, that is easily obtained with the [Math] .NET class.<\/p>\n<pre class=\"nums:false lang:batch decode:true\">PS C:\\&gt; [math]::pi\r\n3.14159265358979<\/pre>\n<p>But this Friday Fun is as much about the journey as anything. I started with finding an algorithm I could use to calculate pi. I decided to use the <a title=\"read the gory math details\" href=\"http:\/\/en.wikipedia.org\/wiki\/Gauss%E2%80%93Legendre_algorithm\" target=\"_blank\">Gauss-Legendre algorithm<\/a>. The general process is to iterate through a series of equations, each pass getting you closer to pi.<\/p>\n<figure style=\"width: 233px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/en.wikipedia.org\/wiki\/Gauss%E2%80%93Legendre_algorithm\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" src=\"http:\/\/upload.wikimedia.org\/math\/f\/f\/9\/ff934ad5f124af53365b41ded2438010.png\" width=\"233\" height=\"130\" \/><\/a><figcaption class=\"wp-caption-text\">The Gauss-Legendre Algorithm<\/figcaption><\/figure>\n<p>Pi is then calculated like this:<\/p>\n<figure style=\"width: 167px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" src=\"http:\/\/upload.wikimedia.org\/math\/5\/1\/f\/51f8f6d1459f3bad60f11882384c6d0d.png\" width=\"167\" height=\"47\" \/><figcaption class=\"wp-caption-text\">calculating pi with the Gauss-Legendre algorithm<\/figcaption><\/figure>\n<p>From my research, I knew what the starting values should be. For reasons that will become clear in a moment, I explicitly defined my variables as arrays.<\/p>\n<pre class=\"lang:ps decode:true\">$a = @(1)\r\n$b = @(1\/[math]::Sqrt(2))\r\n$t = @(1\/4)\r\n$p = @(1)<\/pre>\n<p>As you can see, I still need to rely on the [Math] class for things like the square root of 2. Now the fun part. The algorithm loops and each subsequent value of a variable is based on a calculation of the current variable. My solution was to use a For loop and run the equations for each variable I also decided to evaluate for pi each time through the loop so I could see how close I was getting.<\/p>\n<pre class=\"lang:ps decode:true\">for ($n=0;$n -lt 3;$n++) {\r\n#each time through the array add a new value to each array using the += operator\r\n$a+= ($a[$n]+$b[$n])\/2\r\n$b+= [math]::Sqrt(($a[$n]*$b[$n]))\r\n$t+= $t[$n] - ($p[$n] * ([math]::Pow(($a[$n] - $a[$n+1]),2)))\r\n$p+= 2*$p[$n]\r\n([math]::Pow($a[$n+1] +$b[$n+1],2))\/(4 *($t[$n+1]))\r\n}<\/pre>\n<p>This worked out nicely because $n can serve as the index number for each calculated variable so that I can get the correct ones for the final calculation. The for loop starts with $n=0 and loops while $n is less than or equal to 3. Each time through the loop, $n is incremented by 1 ($n++). You may be wondering why I'm only looping until 3. Well, here's what happens when I run my little script.<\/p>\n<pre class=\"nums:false lang:batch decode:true\">\r\nPS C:\\&gt; Get-Pi.ps1\r\n3.14057925052217\r\n3.14159264621354\r\n3.14159265358979<\/pre>\n<p>No matter how many more times I run the loop, I won't get a value any more precise than 3.14159265358979 which just happens to be the same value as [math]::pi. I thought there might be a way to force PowerShell or .NET to run the calculation to more decimal places but that's a bit beyond my .NET pay grade apparently. But I hoped you picked up something about the For construct or arrays. And don't ask me about the math.I can punch in the numbers but I have no idea what it all means. But I had fun and hope you do to.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 value of pi, that is&#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 blog post: Friday Fun: #PowerShell Pi-romania","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":[233,568,347,534],"class_list":["post-3492","post","type-post","status-publish","format-standard","hentry","category-friday-fun","category-powershell","tag-arrays","tag-friday-fun","tag-math","tag-powershell"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Friday Fun: Pi-romania &#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\/3492\/friday-fun-pi-romania\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Friday Fun: Pi-romania &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"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 value of pi, that is...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/3492\/friday-fun-pi-romania\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2013-10-11T15:41:23+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/8\/8c\/Matheon2.jpg\/320px-Matheon2.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=\"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\\\/3492\\\/friday-fun-pi-romania\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3492\\\/friday-fun-pi-romania\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Friday Fun: Pi-romania\",\"datePublished\":\"2013-10-11T15:41:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3492\\\/friday-fun-pi-romania\\\/\"},\"wordCount\":429,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3492\\\/friday-fun-pi-romania\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/upload.wikimedia.org\\\/wikipedia\\\/commons\\\/thumb\\\/8\\\/8c\\\/Matheon2.jpg\\\/320px-Matheon2.jpg\",\"keywords\":[\"arrays\",\"Friday Fun\",\"math\",\"PowerShell\"],\"articleSection\":[\"Friday Fun\",\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3492\\\/friday-fun-pi-romania\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3492\\\/friday-fun-pi-romania\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3492\\\/friday-fun-pi-romania\\\/\",\"name\":\"Friday Fun: Pi-romania &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3492\\\/friday-fun-pi-romania\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3492\\\/friday-fun-pi-romania\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/upload.wikimedia.org\\\/wikipedia\\\/commons\\\/thumb\\\/8\\\/8c\\\/Matheon2.jpg\\\/320px-Matheon2.jpg\",\"datePublished\":\"2013-10-11T15:41:23+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3492\\\/friday-fun-pi-romania\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3492\\\/friday-fun-pi-romania\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3492\\\/friday-fun-pi-romania\\\/#primaryimage\",\"url\":\"http:\\\/\\\/upload.wikimedia.org\\\/wikipedia\\\/commons\\\/thumb\\\/8\\\/8c\\\/Matheon2.jpg\\\/320px-Matheon2.jpg\",\"contentUrl\":\"http:\\\/\\\/upload.wikimedia.org\\\/wikipedia\\\/commons\\\/thumb\\\/8\\\/8c\\\/Matheon2.jpg\\\/320px-Matheon2.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3492\\\/friday-fun-pi-romania\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Friday Fun\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/friday-fun\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Friday Fun: Pi-romania\"}]},{\"@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: Pi-romania &#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\/3492\/friday-fun-pi-romania\/","og_locale":"en_US","og_type":"article","og_title":"Friday Fun: Pi-romania &#8226; The Lonely Administrator","og_description":"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 value of pi, that is...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3492\/friday-fun-pi-romania\/","og_site_name":"The Lonely Administrator","article_published_time":"2013-10-11T15:41:23+00:00","og_image":[{"url":"http:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/8\/8c\/Matheon2.jpg\/320px-Matheon2.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":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3492\/friday-fun-pi-romania\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3492\/friday-fun-pi-romania\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Friday Fun: Pi-romania","datePublished":"2013-10-11T15:41:23+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3492\/friday-fun-pi-romania\/"},"wordCount":429,"commentCount":0,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3492\/friday-fun-pi-romania\/#primaryimage"},"thumbnailUrl":"http:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/8\/8c\/Matheon2.jpg\/320px-Matheon2.jpg","keywords":["arrays","Friday Fun","math","PowerShell"],"articleSection":["Friday Fun","PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/3492\/friday-fun-pi-romania\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3492\/friday-fun-pi-romania\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3492\/friday-fun-pi-romania\/","name":"Friday Fun: Pi-romania &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3492\/friday-fun-pi-romania\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3492\/friday-fun-pi-romania\/#primaryimage"},"thumbnailUrl":"http:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/8\/8c\/Matheon2.jpg\/320px-Matheon2.jpg","datePublished":"2013-10-11T15:41:23+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3492\/friday-fun-pi-romania\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/3492\/friday-fun-pi-romania\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3492\/friday-fun-pi-romania\/#primaryimage","url":"http:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/8\/8c\/Matheon2.jpg\/320px-Matheon2.jpg","contentUrl":"http:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/8\/8c\/Matheon2.jpg\/320px-Matheon2.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3492\/friday-fun-pi-romania\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Friday Fun","item":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},{"@type":"ListItem","position":2,"name":"Friday Fun: Pi-romania"}]},{"@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":7680,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7680\/friday-fun-back-to-school-with-powershell\/","url_meta":{"origin":3492,"position":0},"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":3492,"position":1},"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":4287,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4287\/pi-in-the-sky\/","url_meta":{"origin":3492,"position":2},"title":"Pi in the Sky","author":"Jeffery Hicks","date":"March 14, 2015","format":false,"excerpt":"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\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\/2015\/03\/031315_2058_PiintheSky1.gif?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1841,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1841\/friday-fun-get-number-object\/","url_meta":{"origin":3492,"position":3},"title":"Friday Fun &#8211; Get Number Object","author":"Jeffery Hicks","date":"November 18, 2011","format":false,"excerpt":"You most likely know that I'm all about the object and the PowerShell pipeline. Everything in PowerShell is an object. Pipe something to Get-Member and you can discover all of the object's properties and methods (ie its members). Some objects, like strings, have many methods but very few properties. Some\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\/11\/gno-300x205.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":633,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/633\/bool-vs-switch\/","url_meta":{"origin":3492,"position":4},"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":[]},{"id":2062,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2062\/export-and-import-hash-tables\/","url_meta":{"origin":3492,"position":5},"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":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3492","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=3492"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3492\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=3492"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=3492"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=3492"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}