{"id":2231,"date":"2012-04-24T11:42:05","date_gmt":"2012-04-24T15:42:05","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=2231"},"modified":"2012-04-24T11:42:05","modified_gmt":"2012-04-24T15:42:05","slug":"convert-boolean-values","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2231\/convert-boolean-values\/","title":{"rendered":"Convert Boolean Values"},"content":{"rendered":"<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/04\/TrueFalse.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/04\/TrueFalse-300x200.png\" alt=\"\" title=\"TrueFalse\" width=\"300\" height=\"200\" class=\"alignleft size-medium wp-image-2236\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/04\/TrueFalse-300x200.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/04\/TrueFalse.png 849w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/a>First, let me state right off the bat that what I have here should be for very special use cases and is NOT something I feel you need to be using at all. Now the use case: You are preparing a report of some sort for a non-technical user and instead of displaying True or False, you need to show Yes or No. Or depending on the object and property some other alternate text; maybe \"Working\"\/\"NotWorking\" or \"Green\"\/\"Red\". I get it. Sometimes you need brain dead output.<\/p>\n<p>Normally, a boolean value and its property should be self sufficient.<\/p>\n<p><code lang=\"DOS\"><br \/>\nPS C:\\> get-process | Select ID,Name,Responding -first 5<\/p>\n<p>                        Id Name                                      Responding<br \/>\n                        -- ----                                      ----------<br \/>\n                      3344 cAudioFilterAgent64                             True<br \/>\n                      3448 cfp                                             True<br \/>\n                      5384 CFSwMgr                                         True<br \/>\n                      1576 chrome                                          True<br \/>\n                      2708 chrome                                          True<br \/>\n<\/code><\/p>\n<p>The Responding property is a Boolean. One way to alter this output is to use a simple hashtable with Select-Object.<\/p>\n<p><code lang=\"DOS\"><br \/>\nPS C:\\> get-process | Select ID,Name,@{Name=\"ProcessIsOK\";Expression={<br \/>\n>> if ($_.Responding) {\"Yes\"} else {\"No\"}}} -first 5<br \/>\n>><\/p>\n<p>                        Id Name                       ProcessIsOK<br \/>\n                        -- ----                       -----------<br \/>\n                      3344 cAudioFilterAgent64        Yes<br \/>\n                      3448 cfp                        Yes<br \/>\n                      5384 CFSwMgr                    Yes<br \/>\n                      1576 chrome                     Yes<br \/>\n                      2708 chrome                     Yes<br \/>\n<\/code><\/p>\n<p>Let me re-iterate that this type of code should be an EXCEPTION. I would hope that 99% of the time you are working with objects and not worrying about parsing text. That said, I threw together a simple function that allows you to substitute your values for $True and $False.<\/p>\n<p><code lang=\"PowerShell\"><br \/>\nFunction Convert-Boolean {<\/p>\n<p>Param(<br \/>\n[Parameter(Position=0,Mandatory=$True,ValueFromPipeline=$True)]<br \/>\n[boolean]$Boolean,<br \/>\n[array]$Alternate=(\"Yes\",\"No\")<br \/>\n)<\/p>\n<p>Begin {<br \/>\n    $T=$Alternate[0]<br \/>\n    $F=$Alternate[1]<br \/>\n}<\/p>\n<p>Process {<br \/>\n    if ($Boolean) {<br \/>\n        Write $T<br \/>\n    }<br \/>\n    else {<br \/>\n        Write $F<br \/>\n    }<br \/>\n}<\/p>\n<p>End {#not used<br \/>\n }<\/p>\n<p>} #function<br \/>\n<\/code><\/p>\n<p>The function takes a Boolean value and writes an alternate text string. The default is Yes\/No. Using this function, here's my revised example:<\/p>\n<p><code lang=\"DOS\"><br \/>\nPS C:\\> get-process | Select ID,Name,@{Name=\"ProcessIsOK\";Expression={<br \/>\n>> $_.Responding | Convert-Boolean }} -first 5<br \/>\n>><\/p>\n<p>                        Id Name                       ProcessIsOK<br \/>\n                        -- ----                       -----------<br \/>\n                      3344 cAudioFilterAgent64        Yes<br \/>\n                      3448 cfp                        Yes<br \/>\n                      5384 CFSwMgr                    Yes<br \/>\n                      1576 chrome                     Yes<br \/>\n                      2708 chrome                     Yes<br \/>\n<\/code><\/p>\n<p>Or using an alternate string:<\/p>\n<p><code lang=\"DOS\"><br \/>\nPS C:\\> get-process | Select ID,Name,@{Name=\"ProcessIsOK\";Expression={<br \/>\n>> $_.Responding | Convert-Boolean -Alternate \"OK\",\"NotOK\"}} -first 5<br \/>\n>><\/p>\n<p>                        Id Name                       ProcessIsOK<br \/>\n                        -- ----                       -----------<br \/>\n                      3344 cAudioFilterAgent64        OK<br \/>\n                      3448 cfp                        OK<br \/>\n                      5384 CFSwMgr                    OK<br \/>\n                      1576 chrome                     OK<br \/>\n                      2708 chrome                     OK<br \/>\n<\/code><br \/>\nThe alternate values are passed as an array.<\/p>\n<p>Again, (can you tell how I feel about this?), this type of PowerShell command should be used in the rare situations where you need brain-dead output. Here's an example of what NOT to do:<\/p>\n<p><code lang=\"DOS\"><br \/>\nPS C:\\> get-process | Select ID,Name,@{Name=\"ProcessIsOK\";Expression={<br \/>\n>> $_.Responding | Convert-Boolean -Alternate \"OK\",\"NotOK\"}} | Where {$_.ProcessIsOK -eq \"NotOK\"}<br \/>\n<\/code><\/p>\n<p>Bad, bad, bad.<\/p>\n<p>All of that said, if you would like to try this out, or perhaps you actually need it, you can download <a href='http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/04\/Convert-Boolean.txt' target='_blank'>Convert-Boolean<\/a> and give it a go.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>First, let me state right off the bat that what I have here should be for very special use cases and is NOT something I feel you need to be using at all. Now the use case: You are preparing a report of some sort for a non-technical user and instead of displaying True or&#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":"","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":[8],"tags":[375,354,534,540],"class_list":["post-2231","post","type-post","status-publish","format-standard","hentry","category-scripting","tag-boolean","tag-convert","tag-powershell","tag-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Convert Boolean Values &#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\/2231\/convert-boolean-values\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Convert Boolean Values &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"First, let me state right off the bat that what I have here should be for very special use cases and is NOT something I feel you need to be using at all. Now the use case: You are preparing a report of some sort for a non-technical user and instead of displaying True or...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/scripting\/2231\/convert-boolean-values\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2012-04-24T15:42:05+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/04\/TrueFalse-300x200.png\" \/>\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\\\/scripting\\\/2231\\\/convert-boolean-values\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2231\\\/convert-boolean-values\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Convert Boolean Values\",\"datePublished\":\"2012-04-24T15:42:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2231\\\/convert-boolean-values\\\/\"},\"wordCount\":275,\"commentCount\":7,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2231\\\/convert-boolean-values\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/04\\\/TrueFalse-300x200.png\",\"keywords\":[\"Boolean\",\"Convert\",\"PowerShell\",\"Scripting\"],\"articleSection\":[\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2231\\\/convert-boolean-values\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2231\\\/convert-boolean-values\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2231\\\/convert-boolean-values\\\/\",\"name\":\"Convert Boolean Values &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2231\\\/convert-boolean-values\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2231\\\/convert-boolean-values\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/04\\\/TrueFalse-300x200.png\",\"datePublished\":\"2012-04-24T15:42:05+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2231\\\/convert-boolean-values\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2231\\\/convert-boolean-values\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2231\\\/convert-boolean-values\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/04\\\/TrueFalse.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2012\\\/04\\\/TrueFalse.png\",\"width\":\"849\",\"height\":\"566\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/2231\\\/convert-boolean-values\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Scripting\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/scripting\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Convert Boolean Values\"}]},{\"@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":"Convert Boolean Values &#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\/2231\/convert-boolean-values\/","og_locale":"en_US","og_type":"article","og_title":"Convert Boolean Values &#8226; The Lonely Administrator","og_description":"First, let me state right off the bat that what I have here should be for very special use cases and is NOT something I feel you need to be using at all. Now the use case: You are preparing a report of some sort for a non-technical user and instead of displaying True or...","og_url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2231\/convert-boolean-values\/","og_site_name":"The Lonely Administrator","article_published_time":"2012-04-24T15:42:05+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/04\/TrueFalse-300x200.png","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\/scripting\/2231\/convert-boolean-values\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2231\/convert-boolean-values\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Convert Boolean Values","datePublished":"2012-04-24T15:42:05+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2231\/convert-boolean-values\/"},"wordCount":275,"commentCount":7,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2231\/convert-boolean-values\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/04\/TrueFalse-300x200.png","keywords":["Boolean","Convert","PowerShell","Scripting"],"articleSection":["Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/2231\/convert-boolean-values\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2231\/convert-boolean-values\/","url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2231\/convert-boolean-values\/","name":"Convert Boolean Values &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2231\/convert-boolean-values\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2231\/convert-boolean-values\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/04\/TrueFalse-300x200.png","datePublished":"2012-04-24T15:42:05+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2231\/convert-boolean-values\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/2231\/convert-boolean-values\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2231\/convert-boolean-values\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/04\/TrueFalse.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/04\/TrueFalse.png","width":"849","height":"566"},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/2231\/convert-boolean-values\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Scripting","item":"https:\/\/jdhitsolutions.com\/blog\/category\/scripting\/"},{"@type":"ListItem","position":2,"name":"Convert Boolean Values"}]},{"@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":1580,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1580\/filtering-empty-values-in-powershell\/","url_meta":{"origin":2231,"position":0},"title":"Filtering Empty Values in PowerShell","author":"Jeffery Hicks","date":"August 3, 2011","format":false,"excerpt":"I saw this tip today and wanted to leave a comment but couldn't see how. So I thought I'd post my comments here. This is actually a question I see often and there are better ways to write this kind of code. The posted tip used an example where you\u2026","rel":"","context":"In &quot;Best Practices&quot;","block_context":{"text":"Best Practices","link":"https:\/\/jdhitsolutions.com\/blog\/category\/best-practices\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3019,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3019\/powershell-scripting-games-2013-impressions\/","url_meta":{"origin":2231,"position":1},"title":"PowerShell Scripting Games 2013 Impressions","author":"Jeffery Hicks","date":"May 13, 2013","format":false,"excerpt":"Now that the PowerShell Scripting Games for 2013 are well underway, I thought I'd share my thoughts and impressions on what I've seen. I'm very impressed with the number of entries and generally the quality is pretty good. But as a judge I see repeated items that bear comment. These\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\/scriptinggames.org\/games-logo.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":4099,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4099\/friday-fun-take-a-chance-with-powershell\/","url_meta":{"origin":2231,"position":2},"title":"Friday Fun &#8211; Take a Chance with PowerShell","author":"Jeffery Hicks","date":"October 10, 2014","format":false,"excerpt":"Last week I showed you my PowerShell Bingo game. While the game itself might be a fun way to pass the time, the real goal was to teach you some PowerShell techniques and concepts without you realizing it. This week, I thought I'd keep with the gaming theme and take\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\/2014\/10\/101014_1431_FridayFunTa1.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":7065,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7065\/powershell-paths-and-errors\/","url_meta":{"origin":2231,"position":3},"title":"PowerShell Paths and Errors","author":"Jeffery Hicks","date":"December 6, 2019","format":false,"excerpt":"As you write PowerShell scripts, it is important that you include error handling. Most of the time, this involves the use of Try\/Catch statements. The tricky thing with Try\/Catch is that you can only catch a terminating exception. There are a few cmdlets that by design will throw a terminating\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-13.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-13.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/12\/image_thumb-13.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/12\/image_thumb-13.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":1335,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1335\/scripting-games-2011-notes-from-the-field\/","url_meta":{"origin":2231,"position":4},"title":"Scripting Games 2011 Notes from the Field","author":"Jeffery Hicks","date":"April 11, 2011","format":false,"excerpt":"I've been making headway in reviewing and judging entries in the 2011 Scripting Games. I know there has been a lot of discussion about the lack of comments and I'm doing what I can with entries I judge, but I'm not guaranteeing anything. What I will do is put down\u2026","rel":"","context":"In &quot;Best Practices&quot;","block_context":{"text":"Best Practices","link":"https:\/\/jdhitsolutions.com\/blog\/category\/best-practices\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":8424,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8424\/hiding-taskbar-search-with-powershell\/","url_meta":{"origin":2231,"position":5},"title":"Hiding TaskBar Search with PowerShell","author":"Jeffery Hicks","date":"May 21, 2021","format":false,"excerpt":"Yesterday I shared a few PowerShell functions for configuring the Windows 10 taskbar to auto-hide. This works great in my virtual desktop when recording my Pluralsight courses. But even when hidden I would still get an annoying white sliver from the search box. So I got rid of that as\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\/05\/show-searchbox.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/show-searchbox.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/show-searchbox.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/05\/show-searchbox.png?resize=700%2C400&ssl=1 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2231","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=2231"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2231\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=2231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=2231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=2231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}