{"id":1319,"date":"2011-04-05T07:38:42","date_gmt":"2011-04-05T11:38:42","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=1319"},"modified":"2011-04-05T07:38:42","modified_gmt":"2011-04-05T11:38:42","slug":"powershell-ise-case-closed","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell-ise\/1319\/powershell-ise-case-closed\/","title":{"rendered":"PowerShell ISE Case Closed"},"content":{"rendered":"<p>When writing a PowerShell script or function, things like indentations, white space and case make a big difference in how easy it is to read and understand your code. Sometimes it can be helpful to have a word or sentence in all upper case so that it stands out. Here is a simple set of commands you can insert into your PowerShell ISE profile to convert selected text to all upper or lower case.<!--more--><\/p>\n<p>The concept is incredibly easy. I trust you know that a string object has method called ToUpper().<\/p>\n<p>[cc lang=\"Powershell\"]<br \/>\nPS C:\\> $s=\"abcdefg\"<br \/>\nPS C:\\> $s.toUpper()<br \/>\nABCDEFG<br \/>\n[\/cc]<\/p>\n<p>The method doesn't change the value of $s, merely returns an uppercase version. There is also a corresponding ToLower() method.  In the ISE, we can use the object model to reference any selected text using<\/p>\n<p>[cc lang=\"Powershell\"]<br \/>\n$psise.CurrentFile.Editor.SelectedText<br \/>\n[\/cc]<\/p>\n<p>This will be a string object which means we can call the ToUpper() and toLower() methods.<\/p>\n<p>[cc lang=\"PowerShell\"]<br \/>\n$psise.CurrentFile.Editor.SelectedText.toUpper()<br \/>\n[\/cc]<\/p>\n<p>But what do we do with the result? We can insert it back into the file using the ISE object model.<\/p>\n<p>[cc lang=\"PowerShell\"]<br \/>\n$psise.currentfile.editor.insertText($psise.CurrentFile.Editor.SelectedText.toUpper())<br \/>\n[\/cc]<\/p>\n<p>Knowing this, I added two lines to my ISE profile script to append a couple of items to the AddOns menu.<\/p>\n<p>[cc lang=\"PowerShell\"]<br \/>\n$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add(\"Convert to uppercase\",<br \/>\n{$psise.currentfile.editor.insertText($psise.CurrentFile.Editor.SelectedText.toUpper())},\"CTRL+ALT+U\") | Out-Null<br \/>\n$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add(\"Convert to lowercase\",<br \/>\n{$psise.currentfile.editor.insertText($psise.CurrentFile.Editor.SelectedText.toLower())},\"CTRL+ALT+L\") | Out-Null<br \/>\n[\/cc]<\/p>\n<p>In the ISE you can run psedit $profile to edit. On my menu I now have two additional options, \"Convert to uppercase\" and \"Convert to lowercase\" with the corresponding keyboard shortcuts. If you don't want any shortcuts use $Null.<\/p>\n<p>You can download these commands in text file <a href='http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/04\/ISE-Casecommands.txt' target='_blank'>here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When writing a PowerShell script or function, things like indentations, white space and case make a big difference in how easy it is to read and understand your code. Sometimes it can be helpful to have a word or sentence in all upper case so that it stands out. Here is a simple set of&#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":[231],"tags":[232,534,234],"class_list":["post-1319","post","type-post","status-publish","format-standard","hentry","category-powershell-ise","tag-ise","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>PowerShell ISE Case Closed &#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-ise\/1319\/powershell-ise-case-closed\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PowerShell ISE Case Closed &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"When writing a PowerShell script or function, things like indentations, white space and case make a big difference in how easy it is to read and understand your code. Sometimes it can be helpful to have a word or sentence in all upper case so that it stands out. Here is a simple set of...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell-ise\/1319\/powershell-ise-case-closed\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2011-04-05T11:38:42+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=\"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-ise\\\/1319\\\/powershell-ise-case-closed\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-ise\\\/1319\\\/powershell-ise-case-closed\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"PowerShell ISE Case Closed\",\"datePublished\":\"2011-04-05T11:38:42+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-ise\\\/1319\\\/powershell-ise-case-closed\\\/\"},\"wordCount\":327,\"commentCount\":6,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"keywords\":[\"ISE\",\"PowerShell\",\"strings\"],\"articleSection\":[\"PowerShell ISE\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-ise\\\/1319\\\/powershell-ise-case-closed\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-ise\\\/1319\\\/powershell-ise-case-closed\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-ise\\\/1319\\\/powershell-ise-case-closed\\\/\",\"name\":\"PowerShell ISE Case Closed &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"datePublished\":\"2011-04-05T11:38:42+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-ise\\\/1319\\\/powershell-ise-case-closed\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-ise\\\/1319\\\/powershell-ise-case-closed\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-ise\\\/1319\\\/powershell-ise-case-closed\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell ISE\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell-ise\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PowerShell ISE Case Closed\"}]},{\"@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":"PowerShell ISE Case Closed &#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-ise\/1319\/powershell-ise-case-closed\/","og_locale":"en_US","og_type":"article","og_title":"PowerShell ISE Case Closed &#8226; The Lonely Administrator","og_description":"When writing a PowerShell script or function, things like indentations, white space and case make a big difference in how easy it is to read and understand your code. Sometimes it can be helpful to have a word or sentence in all upper case so that it stands out. Here is a simple set of...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell-ise\/1319\/powershell-ise-case-closed\/","og_site_name":"The Lonely Administrator","article_published_time":"2011-04-05T11:38:42+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":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-ise\/1319\/powershell-ise-case-closed\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-ise\/1319\/powershell-ise-case-closed\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"PowerShell ISE Case Closed","datePublished":"2011-04-05T11:38:42+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-ise\/1319\/powershell-ise-case-closed\/"},"wordCount":327,"commentCount":6,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"keywords":["ISE","PowerShell","strings"],"articleSection":["PowerShell ISE"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell-ise\/1319\/powershell-ise-case-closed\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-ise\/1319\/powershell-ise-case-closed\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell-ise\/1319\/powershell-ise-case-closed\/","name":"PowerShell ISE Case Closed &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"datePublished":"2011-04-05T11:38:42+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-ise\/1319\/powershell-ise-case-closed\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell-ise\/1319\/powershell-ise-case-closed\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-ise\/1319\/powershell-ise-case-closed\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell ISE","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-ise\/"},{"@type":"ListItem","position":2,"name":"PowerShell ISE Case Closed"}]},{"@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":1324,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell-v2-0\/1324\/powershell-ise-alias-to-command\/","url_meta":{"origin":1319,"position":0},"title":"PowerShell ISE Alias to Command","author":"Jeffery Hicks","date":"April 7, 2011","format":false,"excerpt":"Earlier this week I posted a function that you could incorporate into the PowerShell ISE to convert selected text to upper or lower case. I was challenged to take this a step further and come up with a way to convert aliases to commands. Which is exactly what I did.\u2026","rel":"","context":"In &quot;PowerShell ISE&quot;","block_context":{"text":"PowerShell ISE","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-ise\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1233,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1233\/friday-fun-convertto-text-file\/","url_meta":{"origin":1319,"position":1},"title":"Friday Fun ConvertTo Text File","author":"Jeffery Hicks","date":"March 18, 2011","format":false,"excerpt":"When I'm working on simple PowerShell scripts, I find myself using the PowerShell ISE. When I need to share those scripts on my blog I inevitably need to save the script as a text file so I can post it. I finally realized that instead of the few manual steps,\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":928,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell-v2-0\/928\/powershell-ise-insert-datetime\/","url_meta":{"origin":1319,"position":2},"title":"PowerShell ISE Insert DateTime","author":"Jeffery Hicks","date":"September 15, 2010","format":false,"excerpt":"I still don't leverage the PowerShell Integrated Script Editor (ISE) as much as I should. But after reading a few recent entries from The Scripting Guys on inserting help and headers into a script, I thought I'd dig in a little more. I've a few things to share but today\u2026","rel":"","context":"In &quot;PowerShell ISE&quot;","block_context":{"text":"PowerShell ISE","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-ise\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1340,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/1340\/convert-aliases-with-the-tokenizer\/","url_meta":{"origin":1319,"position":3},"title":"Convert Aliases with the Tokenizer","author":"Jeffery Hicks","date":"April 12, 2011","format":false,"excerpt":"Last week I posted a function you can use in the Windows PowerShell ISE to convert aliases to command definitions. My script relied on regular expressions to seek out and replace aliases. A number of people asked me why I didn't use the PowerShell tokenizer. My answer was that because\u2026","rel":"","context":"In &quot;PowerShell ISE&quot;","block_context":{"text":"PowerShell ISE","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-ise\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1040,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1040\/convert-to-title-case\/","url_meta":{"origin":1319,"position":4},"title":"Convert to Title Case","author":"Jeffery Hicks","date":"January 10, 2011","format":false,"excerpt":"After a long holiday break, some travel and a few training classes its time to get back in the swing of things. Today I have a relatively simple function, that if nothing else demonstrates how to use object methods. The challenge is to take a string of text and convert\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1173,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1173\/get-my-variables\/","url_meta":{"origin":1319,"position":5},"title":"Get My Variables","author":"Jeffery Hicks","date":"March 2, 2011","format":false,"excerpt":"As you might imagine I write a lot of PowerShell scripts and examples. Often my PowerShell Window is open for days at a time. One challenge I have always has is trying to remember what variables I have defined. If I knew the name I'd simply use Get-Variable. What I\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\/1319","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=1319"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1319\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=1319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=1319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=1319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}