{"id":9018,"date":"2022-05-06T10:14:54","date_gmt":"2022-05-06T14:14:54","guid":{"rendered":"https:\/\/jdhitsolutions.com\/blog\/?p=9018"},"modified":"2022-05-06T10:14:57","modified_gmt":"2022-05-06T14:14:57","slug":"an-iron-scripter-warm-up-solution","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9018\/an-iron-scripter-warm-up-solution\/","title":{"rendered":"An Iron Scripter Warm-Up Solution"},"content":{"rendered":"\n<p>We just wrapped up the 2022 edition of the PowerShell+DevOps Global Summit. It was terrific to be with passionate PowerShell professionals again. The culmination of the event is the Iron Scripter Challenge. You can learn more about this year's event and winner <a href=\"https:\/\/github.com\/devops-collective-inc\/Iron-Scripter-2022\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>. But there is more to the Iron Scripter than this event. Throughout the year, you can find scripting challenges to test your PowerShell skill at <a href=\"https:\/\/ironscripter.us\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/ironscripter.us<\/a>. You are encouraged to share links to your solutions in the comments. Today, I have my solutions for a <a href=\"https:\/\/ironscripter.us\/a-powershell-warm-up-exercise\/\" target=\"_blank\" rel=\"noreferrer noopener\">recent challenge<\/a>.<\/p>\n\n\n\n<p>The warm-up challenge was all about manipulating strings. That alone may not sound like much. But the process of discovering how to do it and wrapping it up in a PowerShell function is where the true value lies.<\/p>\n\n\n\n<p><em>Beginner Level: Write PowerShell code to take a string like 'PowerShell' and display it in reverse.<\/em><br><br><em>Intermediate Level: Take a sentence like, \"This is how you can improve your PowerShell skills.\"  and write PowerShell code to display the entire sentence in reverse with each word also reversed. You should be able to encode and decode text. Ideally, your functions should take pipeline input.<\/em> <em>For bonus points, toggle upper and lower case when reversing the word.<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Reversing Text<\/h2>\n\n\n\n<p>PowerShell treats every string of text as an array. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">PS C:\\> $w = \"PowerShell\"\nPS C:\\> $w[0]\nP<\/code><\/pre>\n\n\n\n<p>Using the range operator, I can get elements in reverse.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">PS C:\\> $w[-1..-($w.length)]\nl\nl\ne\nh\nS\nr\ne\nw\no\nP<\/code><\/pre>\n\n\n\n<p>Use the Join operator to put the characters back together again.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">PS C:\\> $w[-1..-($w.length)] -join ''\nllehSrewoP<\/code><\/pre>\n\n\n\n<p>With this core concept validated, it is simple enough to wrap it in a function.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Function Invoke-ReverseWord {\n    [cmdletbinding()]\n    [OutputType(\"string\")]\n    Param(\n        [Parameter(\n            Position = 0,\n            Mandatory,\n            ValueFromPipeline,\n            HelpMessage = \"Enter a word.\"\n        )]\n        [ValidateNotNullOrEmpty()]\n        [string]$Word\n    )\n\n    Begin {\n        Write-Verbose \"[$((Get-Date).TimeofDay) BEGIN  ] Starting $($myinvocation.mycommand)\"\n    } #begin\n    Process {\n        Write-Verbose \"[$((Get-Date).TimeofDay) PROCESS] Processing $Word\"\n        Write-Verbose \"[$((Get-Date).TimeofDay) PROCESS] Word length is $($Word.length)\"\n        #get the characters in reverse and join into a string\n        ($Word[-1.. -($Word.length)]) -join ''\n\n    } #process\n    End {\n        Write-Verbose \"[$((Get-Date).TimeofDay) END    ] Ending $($myinvocation.mycommand)\"\n    } #end\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Reversing a Sentence<\/h2>\n\n\n\n<p>Reversing words in a sentence follows the same principle. I can split the sentence into an array of words and then access the elements in reverse.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">PS C:\\> $t = \"This is how you can improve your PowerShell skills\"\nPS C:\\> $words = $t.split()\nPS C:\\> $words[-1..-($words.count)]\nskills\nPowerShell\nyour\nimprove\ncan\nyou\nhow\nis\nThis<\/code><\/pre>\n\n\n\n<p>Again, I can join the words with a space. If I wanted to, I could reverse each word as well. That's what this function does.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Function Invoke-ReverseText {\n    [CmdletBinding()]\n    [OutputType(\"string\")]\n    Param(\n        [Parameter(\n            Position = 0,\n            Mandatory,\n            ValueFromPipeline,\n            HelpMessage = \"Enter a phrase.\"\n        )]\n        [ValidateNotNullOrEmpty()]\n        [ValidatePattern(\"\\s\")]\n        [string]$Text\n    )\n    Begin {\n        Write-Verbose \"[$((Get-Date).TimeofDay) BEGIN  ] Starting $($myinvocation.mycommand)\"\n    } #begin\n    Process {\n        Write-Verbose \"[$((Get-Date).TimeofDay) PROCESS] Processing $Text\"\n        #split the phrase on white spaces and reverse each word\n        $words = $Text.split() | Invoke-ReverseWord\n        Write-Verbose \"[$((Get-Date).TimeofDay) PROCESS] Reversed $($words.count) words\"\n        ($words[-1.. - $($words.count)]) -join \" \"\n    } #process\n    End {\n        Write-Verbose \"[$((Get-Date).TimeofDay) END    ] Ending $($myinvocation.mycommand)\"\n    } #end\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">PS C:\\> Invoke-ReverseText \"This is how you can improve your PowerShell skills\"\nslliks llehSrewoP ruoy evorpmi nac uoy woh si sihT\nPS C:\\> Invoke-ReverseText \"This is how you can improve your PowerShell skills\" | invoke-reversetext\nThis is how you can improve your PowerShell skills\nPS C:\\><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Toggle Case<\/h2>\n\n\n\n<p>Figuring out how to toggle case is a bit trickier. Each letter in a word is technically a [Char] type object.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">PS C:\\> $t = \"PowerShell\"\nPS C:\\> $t[0]\nP\nPS C:\\> $t[0].gettype()\n\nIsPublic IsSerial Name                                     BaseType\n-------- -------- ----                                     --------\nTrue     True     Char                                     System.ValueType<\/code><\/pre>\n\n\n\n<p>[Char] objects have a numeric value.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">PS C:\\> $t[0] -as [int]\n80<\/code><\/pre>\n\n\n\n<p>On my en-US system, upper-case alphabet characters fall within the range of 65-90. Lower-case letters are 97-112.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">PS C:\\> [char]80     \nP\nPS C:\\> 100 -as [char]\nd<\/code><\/pre>\n\n\n\n<p>To toggle case, I need to get the numeric value of each character and then invoke the toLower() or toUpper() method as required.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Function Invoke-ToggleCase {\n    [cmdletbinding()]\n    [OutputType(\"String\")]\n    Param(\n        [Parameter(\n            Position = 0,\n            Mandatory,\n            ValueFromPipeline,\n            HelpMessage = \"Enter a word.\"\n        )]\n        [ValidateNotNullOrEmpty()]\n        [string]$Word\n    )\n\n    Begin {\n        Write-Verbose \"[$((Get-Date).TimeofDay) BEGIN  ] Starting $($myinvocation.mycommand)\"\n    } #begin\n    Process {\n        Write-Verbose \"[$((Get-Date).TimeofDay) PROCESS] Processing $Word\"\n        $Toggled = $Word.ToCharArray() | ForEach-Object {\n            $i = $_ -as [int]\n            if ($i -ge 65 -AND $i -le 90) {\n                #toggle lower\n                $_.ToString().ToLower()\n            }\n            elseif ($i -ge 97 -AND $i -le 122) {\n                #toggle upper\n                $_.ToString().ToUpper()\n            }\n            else {\n                $_.ToString()\n            }\n        } #foreach-object\n\n        #write the new word to the pipeline\n        $toggled -join ''\n\n    } #process\n    End {\n        Write-Verbose \"[$((Get-Date).TimeofDay) END    ] Ending $($myinvocation.mycommand)\"\n    } #end\n\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">PS C:\\> invoke-togglecase $t\npOWERsHELL<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Putting It All Together<\/h2>\n\n\n\n<p>Here's a function that does it all.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Function Invoke-ReverseTextToggle {\n    [CmdletBinding()]\n    [OutputType(\"string\")]\n    Param(\n        [Parameter(\n            Position = 0,\n            Mandatory,\n            ValueFromPipeline,\n            HelpMessage = \"Enter a phrase.\"\n        )]\n        [ValidateNotNullOrEmpty()]\n        [ValidatePattern(\"\\s\")]\n        [string]$Text\n    )\n    Begin {\n        Write-Verbose \"[$((Get-Date).TimeofDay) BEGIN  ] Starting $($myinvocation.mycommand)\"\n    } #begin\n    Process {\n        Write-Verbose \"[$((Get-Date).TimeofDay) PROCESS] Processing $Text\"\n        #split the phrase on white spaces and reverse each word\n        $words = $Text.split() | Invoke-ToggleCase | Invoke-ReverseWord\n        Write-Verbose \"[$((Get-Date).TimeofDay) PROCESS] Reversed $($words.count) words\"\n        ($words[-1.. - $($words.count)]) -join \" \"\n    } #process\n    End {\n        Write-Verbose \"[$((Get-Date).TimeofDay) END    ] Ending $($myinvocation.mycommand)\"\n    } #end\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">PS C:\\> Invoke-ReverseTextToggle \"This is how YOU can improve your PowerShell skills\"\nSLLIKS LLEHsREWOp RUOY EVORPMI NAC uoy WOH SI SIHt\nPS C:\\>\nPS C:\\> Invoke-ReverseTextToggle \"This is how YOU can improve your PowerShell skills\" | Invoke-ReverseTextToggle\nThis is how YOU can improve your PowerShell skills<\/code><\/pre>\n\n\n\n<p>After putting that together, I realized someone might not want all of the transformations. Maybe they only want to toggle case and reverse words. Here's a function that offers flexibility.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Function Convert-Text {\n    &lt;#\n    This function relies on some of the previous functions or the functions could be nested\n    inside the Begin block\n\n    Order of operation:\n      toggle case\n      reverse word\n      reverse text\n    #>\n    [cmdletbinding()]\n    Param(\n        [Parameter(Position = 0, Mandatory, ValueFromPipeline)]\n        [ValidateNotNullOrEmpty()]\n        [string]$Text,\n        [Parameter(HelpMessage = \"Reverse each word of text\")]\n        [switch]$ReverseWord,\n        [Parameter(HelpMessage = \"Toggle the case of the text\")]\n        [switch]$ToggleCase,\n        [Parameter(HelpMessage = \"Reverse the entire string of text\")]\n        [switch]$ReverseText\n    )\n    Begin {\n        Write-Verbose \"[$((Get-Date).TimeofDay) BEGIN  ] Starting $($myinvocation.mycommand)\"\n    } #begin\n\n    Process {\n        Write-Verbose \"[$((Get-Date).TimeofDay) PROCESS] Converting $Text\"\n        $words = $text.Split()\n        if ($ToggleCase) {\n            Write-Verbose \"toggling case\"\n            $words = $words | Invoke-ToggleCase\n        }\n        If ($reverseWord) {\n            Write-Verbose \"reversing words\"\n            $words = $words | Invoke-ReverseWord\n        }\n        if ($ReverseText) {\n            Write-Verbose \"reversing text\"\n            $words = ($words[-1.. - $($words.count)])\n        }\n        #write the converted text to the pipeline\n        $words -join \" \"\n\n    } #process\n\n    End {\n        Write-Verbose \"[$((Get-Date).TimeofDay) END    ] Ending $($myinvocation.mycommand)\"\n    } #end\n\n} #close Convert-Text<\/code><\/pre>\n\n\n\n<p>As written, this function relies on some of the earlier functions.  But now, the user has options.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">PS C:\\> convert-text \"I AM an Iron Scripter!\" -ToggleCase\ni am AN iRON sCRIPTER!\nPS C:\\>\nPS C:\\> convert-text \"I AM an Iron Scripter!\" -ReverseWord\nI MA na norI !retpircS\nPS C:\\>\nPS C:\\> convert-text \"I AM an Iron Scripter!\" -ReverseWord -ToggleCase\ni ma NA NORi !RETPIRCs\nPS C:\\>\nPS C:\\> convert-text \"I AM an Iron Scripter!\" -Reversetext -ToggleCase -ReverseWord\n!RETPIRCs NORi NA ma i\nPS C:\\>\nPS C:\\> convert-text \"I AM an Iron Scripter!\" -Reversetext -ToggleCase -ReverseWord | convert-text -ReverseWord -ToggleCase -ReverseText   \nI AM an Iron Scripter!<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Challenge Yourself<\/h2>\n\n\n\n<p>If you have any questions about my code samples, please feel free to leave a comment. I also want to emphasize that my solutions are <strong>not <\/strong>the only way to achieve these results. There is value in comparing your work with others. I strongly encourage you to watch for future Iron Scripter challenges and tackle as much as possible. However, you don't have to wait. There are plenty of existing challenges on the site for all PowerShell scripting levels. Comments may be closed, so you can't share your solution, but that shouldn't prevent you from ramping your skills.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We just wrapped up the 2022 edition of the PowerShell+DevOps Global Summit. It was terrific to be with passionate PowerShell professionals again. The culmination of the event is the Iron Scripter Challenge. You can learn more about this year&#8217;s event and winner here. But there is more to the Iron Scripter than this event. Throughout&#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 on the blog: My solutions for an Iron Scripter Text Challenge #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":[4,8],"tags":[618,534,540],"class_list":["post-9018","post","type-post","status-publish","format-standard","hentry","category-powershell","category-scripting","tag-iron-scripter","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>An Iron Scripter Warm-Up Solution &#8226; The Lonely Administrator<\/title>\n<meta name=\"description\" content=\"Here are my PowerShell solutions for a recent Iron Scripter warm-up scripting challenge. Problem solving is a great way to improve coding skills.\" \/>\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\/9018\/an-iron-scripter-warm-up-solution\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"An Iron Scripter Warm-Up Solution &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"Here are my PowerShell solutions for a recent Iron Scripter warm-up scripting challenge. Problem solving is a great way to improve coding skills.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/9018\/an-iron-scripter-warm-up-solution\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2022-05-06T14:14:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-05-06T14:14:57+00:00\" \/>\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=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/9018\\\/an-iron-scripter-warm-up-solution\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/9018\\\/an-iron-scripter-warm-up-solution\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"An Iron Scripter Warm-Up Solution\",\"datePublished\":\"2022-05-06T14:14:54+00:00\",\"dateModified\":\"2022-05-06T14:14:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/9018\\\/an-iron-scripter-warm-up-solution\\\/\"},\"wordCount\":545,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"keywords\":[\"Iron Scripter\",\"PowerShell\",\"Scripting\"],\"articleSection\":[\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/9018\\\/an-iron-scripter-warm-up-solution\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/9018\\\/an-iron-scripter-warm-up-solution\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/9018\\\/an-iron-scripter-warm-up-solution\\\/\",\"name\":\"An Iron Scripter Warm-Up Solution &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"datePublished\":\"2022-05-06T14:14:54+00:00\",\"dateModified\":\"2022-05-06T14:14:57+00:00\",\"description\":\"Here are my PowerShell solutions for a recent Iron Scripter warm-up scripting challenge. Problem solving is a great way to improve coding skills.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/9018\\\/an-iron-scripter-warm-up-solution\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/9018\\\/an-iron-scripter-warm-up-solution\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/9018\\\/an-iron-scripter-warm-up-solution\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"An Iron Scripter Warm-Up Solution\"}]},{\"@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":"An Iron Scripter Warm-Up Solution &#8226; The Lonely Administrator","description":"Here are my PowerShell solutions for a recent Iron Scripter warm-up scripting challenge. Problem solving is a great way to improve coding skills.","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\/9018\/an-iron-scripter-warm-up-solution\/","og_locale":"en_US","og_type":"article","og_title":"An Iron Scripter Warm-Up Solution &#8226; The Lonely Administrator","og_description":"Here are my PowerShell solutions for a recent Iron Scripter warm-up scripting challenge. Problem solving is a great way to improve coding skills.","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9018\/an-iron-scripter-warm-up-solution\/","og_site_name":"The Lonely Administrator","article_published_time":"2022-05-06T14:14:54+00:00","article_modified_time":"2022-05-06T14:14:57+00:00","author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9018\/an-iron-scripter-warm-up-solution\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9018\/an-iron-scripter-warm-up-solution\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"An Iron Scripter Warm-Up Solution","datePublished":"2022-05-06T14:14:54+00:00","dateModified":"2022-05-06T14:14:57+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9018\/an-iron-scripter-warm-up-solution\/"},"wordCount":545,"commentCount":3,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"keywords":["Iron Scripter","PowerShell","Scripting"],"articleSection":["PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/9018\/an-iron-scripter-warm-up-solution\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9018\/an-iron-scripter-warm-up-solution\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9018\/an-iron-scripter-warm-up-solution\/","name":"An Iron Scripter Warm-Up Solution &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"datePublished":"2022-05-06T14:14:54+00:00","dateModified":"2022-05-06T14:14:57+00:00","description":"Here are my PowerShell solutions for a recent Iron Scripter warm-up scripting challenge. Problem solving is a great way to improve coding skills.","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9018\/an-iron-scripter-warm-up-solution\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/9018\/an-iron-scripter-warm-up-solution\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/9018\/an-iron-scripter-warm-up-solution\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"An Iron Scripter Warm-Up Solution"}]},{"@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":8107,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8107\/scripting-challenge-meetup\/","url_meta":{"origin":9018,"position":0},"title":"Scripting Challenge Meetup","author":"Jeffery Hicks","date":"February 1, 2021","format":false,"excerpt":"As you probably know, I am the PowerShell problem master behind the challenges from the Iron Scripter site. Solving a PowerShell scripting challenge is a great way to test your skills and expand your knowledge. The final result is merely a means to an end. How you get there and\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\/2021\/02\/rubik.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":7489,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7489\/powershell-word-play\/","url_meta":{"origin":9018,"position":1},"title":"PowerShell Word Play","author":"Jeffery Hicks","date":"May 19, 2020","format":false,"excerpt":"A few weeks ago an Iron Scripter PowerShell challenge was issued that involved playing with words and characters. Remember, the Iron Scripter challenges aren't intended to create meaningful, production worthy code. They are designed to help you learn PowerShell fundamentals and scripting techniques. This particular challenge was aimed at beginner\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\/2020\/05\/doublechar.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/doublechar.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/doublechar.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/doublechar.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/doublechar.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/doublechar.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":7559,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7559\/an-expanded-powershell-scripting-inventory-tool\/","url_meta":{"origin":9018,"position":2},"title":"An Expanded PowerShell Scripting Inventory Tool","author":"Jeffery Hicks","date":"June 19, 2020","format":false,"excerpt":"The other day I shared my code that I worked up to solve an Iron Scripter PowerShell challenge. One of the shortcomings was that I didn't address a challenge to include a property that would indicate what file was using a given command. I also felt I could do better\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\/2020\/06\/get-psscriptinventory.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/06\/get-psscriptinventory.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/06\/get-psscriptinventory.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/06\/get-psscriptinventory.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/06\/get-psscriptinventory.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/06\/get-psscriptinventory.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":7680,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7680\/friday-fun-back-to-school-with-powershell\/","url_meta":{"origin":9018,"position":3},"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":8236,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8236\/solving-another-powershell-math-challenge\/","url_meta":{"origin":9018,"position":4},"title":"Solving Another PowerShell Math Challenge","author":"Jeffery Hicks","date":"March 22, 2021","format":false,"excerpt":"Last month, the Iron Scripter Chairman posted a \"fun\" PowerShell scripting challenge. Actually, a few math-related challenges . As with all these challenges, the techniques and concepts you use to solve the challenge are more important than the result itself. Here's how I approached the problems. Problem #1 The first\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\/2021\/03\/get-possiblesum.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/get-possiblesum.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/03\/get-possiblesum.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":7024,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7024\/managing-the-recycle-bin-with-powershell\/","url_meta":{"origin":9018,"position":5},"title":"Managing the Recycle Bin with PowerShell","author":"Jeffery Hicks","date":"December 3, 2019","format":false,"excerpt":"A while ago, I posted an Iron Scripter challenge asking you to write some PowerShell code for working with items in the recycle bin. You were asked to calculate how much space the recycle bin is using and then restore a file. If you'd prefer, stop reading this post, check\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\/2019\/12\/image_thumb-7.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/12\/image_thumb-7.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/12\/image_thumb-7.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/12\/image_thumb-7.png?resize=700%2C400&ssl=1 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/9018","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=9018"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/9018\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=9018"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=9018"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=9018"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}