{"id":940,"date":"2010-09-17T08:38:25","date_gmt":"2010-09-17T12:38:25","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=940"},"modified":"2011-03-28T08:24:37","modified_gmt":"2011-03-28T12:24:37","slug":"friday-fun-playing-with-strings","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/scripting\/940\/friday-fun-playing-with-strings\/","title":{"rendered":"Friday Fun Playing with Strings"},"content":{"rendered":"<p>While I was busy working, it turned into Friday which means time for a little PowerShell fun. I can't say you'll find any deep, meaningful, production use from today's post, but you might pick up a few techniques, which is really the point. Today we're going to have some fun with strings and arrays.<!--more--><\/p>\n<p>The first thing I want to do is reverse a string. So that a string like \"Every good boy deserves fudge\" becomes \"egduf sevresed yob doog yrevE\". This is also a great example of how we can take advantage of the object nature of PowerShell.  Without nitpicking the semantics, I'm not parsing the string to get a reverse version, I'm taking advantage of objects.  First off, a string object has a single property: length.<br \/>\n[cc lang=\"PowerShell\"]<br \/>\nPS C:\\> $s=\"PowerShell\"<br \/>\nPS C:\\> $s.length<br \/>\n10<br \/>\nPS C:\\><br \/>\n[\/cc]<br \/>\nThe string object is also an array of characters which means I can access any character I want by an index number. Remember PowerShell arrays start at 0.<br \/>\n[cc lang=\"PowerShell\"]<br \/>\nPS C:\\> $s[4]<br \/>\nr<br \/>\nPS C:\\> $s[5]<br \/>\nS<br \/>\nPS C:\\> $s[0,6]<br \/>\nP<br \/>\nh<br \/>\nPS C:\\> $s[3..6]<br \/>\ne<br \/>\nr<br \/>\nS<br \/>\nh<br \/>\nPS C:\\><br \/>\n[\/cc]<br \/>\nSo to reverse the string, all I need to do is get the characters in reverse order and build a new string.<br \/>\n[cc lang=\"PowerShell\"]<br \/>\nPS C:\\> [string]$reverse=\"\"<br \/>\nPS C:\\> for ($i=($s.length-1);$i -ge 0; $i--) {<br \/>\n>>                 #append to $reverse<br \/>\n>>                 $reverse+=$s[$i]<br \/>\n>>              }<br \/>\n>><br \/>\nPS C:\\> $reverse<br \/>\nllehSrewoP<br \/>\nPS C:\\><br \/>\n[\/cc]<br \/>\nI defined an empty string object, and then using the FOR construct start at the end of $s and add each character to $reverse. Taking this a step further I put together a function, Out-Reverse, so that you could pipe strings, or even entire text files to it. Each reversed line will be written to the pipeline.<br \/>\n[cc lang=\"PowerShell\"]<br \/>\nFunction Out-Reverse {<\/p>\n<p>Param(<br \/>\n[Parameter(Position=0,Mandatory=$True,HelpMessage=\"Enter a line of text\",<br \/>\nValueFromPipeline=$True)]<br \/>\n[ValidateNotNullorEmpty()]<br \/>\n[string[]]$Text<br \/>\n)<\/p>\n<p>Process {<br \/>\n    ForEach ($str in $Text) {<br \/>\n        Write-Verbose \"Reversing: $str\"<br \/>\n        $str | foreach {<br \/>\n            #define an empty variable for the reversed result<br \/>\n            [string]$reverse=\"\"<br \/>\n            for ($i=($_.length-1);$i -ge 0; $i--) {<br \/>\n                #append to $reverse<br \/>\n                $reverse+=$_[$i]<br \/>\n             }<br \/>\n             #write the result<br \/>\n            Write-Host \"Reversed\" -ForegroundColor Yellow<br \/>\n            $reverse<br \/>\n        }<br \/>\n    }# Foreach<br \/>\n} #process<\/p>\n<p>} #end function<br \/>\n[\/cc]<br \/>\nWant to see it in action?<br \/>\n[cc lang=\"PowerShell\"]<br \/>\nPS C:\\> \"The quick brown fox jumped over the lazy dog\" | out-reverse<br \/>\nReversed<br \/>\ngod yzal eht revo depmuj xof nworb kciuq ehT<br \/>\n[\/cc]The function uses Write-Host to show you what happened but you could comment that out. Now let's look at one other way to play with strings.<\/p>\n<p>Since we know the string is an array of characters which we can access by index number. let's create a randomized version of the string. Naturally I made a function.<br \/>\n[cc lang=\"PowerShell\"]<br \/>\nFunction Out-Random {<\/p>\n<p>Param(<br \/>\n[Parameter(Position=0,Mandatory=$True,HelpMessage=\"Enter a line of text\",<br \/>\nValueFromPipeline=$True)]<br \/>\n[ValidateNotNullorEmpty()]<br \/>\n[string[]]$Text<br \/>\n)<\/p>\n<p>Process {<br \/>\n    ForEach ($str in $Text) {<br \/>\n       Write-Verbose \"Randomizing: $str\"<br \/>\n        #initialize an empty array<br \/>\n        $a=@()<br \/>\n        Write-Verbose \"Generating random number array\"<br \/>\n        do {<br \/>\n            #get a random number between 0 and length of string<br \/>\n            $x=get-random -Minimum 0 -Maximum $str.length<br \/>\n            #add the number to the array if it doesn't already exist<br \/>\n            if (-not ($a -contains $x)) {<br \/>\n               $a+=$x<br \/>\n            }<br \/>\n            #repeat until every number has been added to the array<br \/>\n        } Until ($a.count -eq $str.length)<\/p>\n<p>        #define a varialble for the randomized output<br \/>\n        [string]$randout=\"\"<br \/>\n        Write-Verbose \"Constructing random output\"<br \/>\n        #get the corresponding random element and construct the random output<br \/>\n        $a | foreach { $randout+=$str[$_] }<br \/>\n        #write the result<br \/>\n        Write-Host \"Randomized\" -ForegroundColor Yellow<br \/>\n        $randout<br \/>\n    } #foreach<br \/>\n } #Process<br \/>\n} #end function<br \/>\n[\/cc]<\/p>\n<p>Now I couldn't just get a random number for each character in the array because I'd end up with duplicates. If the string was 10 characters long, then I need an array of numbers 0 to 9 in a random order. To accomplish my goal, I created an empty array. Then using the Get-Random cmdlet, I generated a number between 0 and the string length. If the number did not already exist in my empty array I add it, otherwise I looped and tried again. I hope this is a good example of a Do\/Until loop.<br \/>\n[cc lang=\"PowerShell\"]<br \/>\n$a=@()<br \/>\n        Write-Verbose \"Generating random number array\"<br \/>\n        do {<br \/>\n            #get a random number between 0 and length of string<br \/>\n            $x=get-random -Minimum 0 -Maximum $str.length<br \/>\n            #add the number to the array if it doesn't already exist<br \/>\n            if (-not ($a -contains $x)) {<br \/>\n               $a+=$x<br \/>\n            }<br \/>\n            #repeat until every number has been added to the array<br \/>\n        } Until ($a.count -eq $str.length)<br \/>\n[\/cc]<br \/>\nThe process continues until the number of items in my array equals the length of the string. Now, it's just a matter of enumerating the array of random numbers, getting the corresponding character from the string array and building a new string.<br \/>\n[cc lang=\"Powershell\"]<br \/>\n [string]$randout=\"\"<br \/>\n        Write-Verbose \"Constructing random output\"<br \/>\n        #get the corresponding random element and construct the random output<br \/>\n        $a | foreach { $randout+=$str[$_] }<br \/>\n[\/cc]<br \/>\nMy Out-Reverse function in action:<br \/>\n[cc lang=\"PowerShell\"]<br \/>\nPS C:\\> \"The quick brown fox jumped over the lazy dog\" | out-random<br \/>\nRandomized<br \/>\neine gdoxk mu   o buazloeorcfhqv dt pjThwyre<br \/>\n[\/cc]<br \/>\nYou can have even more fun by piping between functions.<br \/>\n[cc lang=\"PowerShell\"]<br \/>\nPS C:\\> \"Every good boy deserves fudge\" | out-reverse | out-random<br \/>\nReversed<br \/>\nRandomized<br \/>\nsdr yedesbdreoeyefvEv og guo<br \/>\nPS C:\\> \"Every good boy deserves fudge\" | out-random | out-reverse<br \/>\nRandomized<br \/>\nReversed<br \/>\n dfdgeuoesyb rogs er dyeEvevo<br \/>\nPS C:\\> \"Every good boy deserves fudge\" | out-reverse | out-reverse<br \/>\nReversed<br \/>\nReversed<br \/>\nEvery good boy deserves fudge<br \/>\n[\/cc]<br \/>\nThe last example is kind of silly. But it shows you can undo the change. Actually, if you save the randomized array ($a), you can also \"decode\" the randomized string.  But I'll leave that for you to play with. A hint: you'll most likely need a hash table.<\/p>\n<p>So have some fun today and maybe even learn something new. You can download a script file with both functions <a href='http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/09\/stringfun.txt' target=\"_blank\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While I was busy working, it turned into Friday which means time for a little PowerShell fun. I can&#8217;t say you&#8217;ll find any deep, meaningful, production use from today&#8217;s post, but you might pick up a few techniques, which is really the point. Today we&#8217;re going to have some fun with strings and arrays.<\/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":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[271,75,8],"tags":[233,32,534,234],"class_list":["post-940","post","type-post","status-publish","format-standard","hentry","category-friday-fun","category-powershell-v2-0","category-scripting","tag-arrays","tag-functions","tag-powershell","tag-strings"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Friday Fun Playing with Strings &#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\/scripting\/940\/friday-fun-playing-with-strings\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Friday Fun Playing with Strings &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"While I was busy working, it turned into Friday which means time for a little PowerShell fun. I can&#039;t say you&#039;ll find any deep, meaningful, production use from today&#039;s post, but you might pick up a few techniques, which is really the point. Today we&#039;re going to have some fun with strings and arrays.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/scripting\/940\/friday-fun-playing-with-strings\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2010-09-17T12:38:25+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2011-03-28T12:24:37+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=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/940\\\/friday-fun-playing-with-strings\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/940\\\/friday-fun-playing-with-strings\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Friday Fun Playing with Strings\",\"datePublished\":\"2010-09-17T12:38:25+00:00\",\"dateModified\":\"2011-03-28T12:24:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/940\\\/friday-fun-playing-with-strings\\\/\"},\"wordCount\":982,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"keywords\":[\"arrays\",\"functions\",\"PowerShell\",\"strings\"],\"articleSection\":[\"Friday Fun\",\"PowerShell v2.0\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/940\\\/friday-fun-playing-with-strings\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/940\\\/friday-fun-playing-with-strings\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/940\\\/friday-fun-playing-with-strings\\\/\",\"name\":\"Friday Fun Playing with Strings &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"datePublished\":\"2010-09-17T12:38:25+00:00\",\"dateModified\":\"2011-03-28T12:24:37+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/940\\\/friday-fun-playing-with-strings\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/940\\\/friday-fun-playing-with-strings\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/940\\\/friday-fun-playing-with-strings\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Friday Fun\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/friday-fun\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Friday Fun Playing with Strings\"}]},{\"@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 Playing with Strings &#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\/scripting\/940\/friday-fun-playing-with-strings\/","og_locale":"en_US","og_type":"article","og_title":"Friday Fun Playing with Strings &#8226; The Lonely Administrator","og_description":"While I was busy working, it turned into Friday which means time for a little PowerShell fun. I can't say you'll find any deep, meaningful, production use from today's post, but you might pick up a few techniques, which is really the point. Today we're going to have some fun with strings and arrays.","og_url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/940\/friday-fun-playing-with-strings\/","og_site_name":"The Lonely Administrator","article_published_time":"2010-09-17T12:38:25+00:00","article_modified_time":"2011-03-28T12:24:37+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":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/940\/friday-fun-playing-with-strings\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/940\/friday-fun-playing-with-strings\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Friday Fun Playing with Strings","datePublished":"2010-09-17T12:38:25+00:00","dateModified":"2011-03-28T12:24:37+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/940\/friday-fun-playing-with-strings\/"},"wordCount":982,"commentCount":3,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"keywords":["arrays","functions","PowerShell","strings"],"articleSection":["Friday Fun","PowerShell v2.0","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/940\/friday-fun-playing-with-strings\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/940\/friday-fun-playing-with-strings\/","url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/940\/friday-fun-playing-with-strings\/","name":"Friday Fun Playing with Strings &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"datePublished":"2010-09-17T12:38:25+00:00","dateModified":"2011-03-28T12:24:37+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/940\/friday-fun-playing-with-strings\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/940\/friday-fun-playing-with-strings\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/940\/friday-fun-playing-with-strings\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Friday Fun","item":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},{"@type":"ListItem","position":2,"name":"Friday Fun Playing with Strings"}]},{"@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":3925,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3925\/friday-fun-reverse-powershell\/","url_meta":{"origin":940,"position":0},"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":1389,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1389\/friday-fun-randomness-abounds\/","url_meta":{"origin":940,"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":2720,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2720\/silly-saturday-powershell-palindromes\/","url_meta":{"origin":940,"position":2},"title":"Silly Saturday PowerShell Palindromes","author":"Jeffery Hicks","date":"January 19, 2013","format":false,"excerpt":"Normally I post amusing PowerShell-related content on Fridays as part of my Friday Fun series. These are light-hearted articles about using PowerShell. Almost always they are not practical but they serve as a learning vehicle. My topic this week seems extra silly so I'm moving it to Saturday. I'm a\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"242px-Sator_Square_at_Opp\u00e8de","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/01\/242px-Sator_Square_at_Opp%C3%A8de-150x150.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":2425,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/2425\/friday-fun-expand-environmental-variables-in-powershell-strings\/","url_meta":{"origin":940,"position":3},"title":"Friday Fun: Expand Environmental Variables in PowerShell Strings","author":"Jeffery Hicks","date":"June 29, 2012","format":false,"excerpt":"This week I was working on a project that involved using the %PATH% environmental variable. The challenge was that I have some entries that look like this: %SystemRoot%\\system32\\WindowsPowerShell\\v1.0\\. When I try to use that path in PowerShell, it complains because it doesn't expand %SystemRoot%. What I needed was a way\u2026","rel":"","context":"In &quot;CommandLine&quot;","block_context":{"text":"CommandLine","link":"https:\/\/jdhitsolutions.com\/blog\/category\/commandline\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/06\/powershellvariable-300x71.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1085,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1085\/friday-fun-lets-play-bingo\/","url_meta":{"origin":940,"position":4},"title":"Friday Fun: Let&#8217;s Play Bingo!","author":"Jeffery Hicks","date":"January 28, 2011","format":false,"excerpt":"Today Campers we're playing Bingo. Or at least getting ready to. This week I have some PowerShell code that will create a BINGO card. For those of you outside of North America you might need to take a crash course on this game. But even if you don't play, this\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":1554,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1554\/friday-fun-powershell-powerball-numbers\/","url_meta":{"origin":940,"position":5},"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":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/940","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=940"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/940\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=940"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=940"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=940"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}