{"id":1324,"date":"2011-04-07T16:24:08","date_gmt":"2011-04-07T20:24:08","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=1324"},"modified":"2011-04-07T16:24:08","modified_gmt":"2011-04-07T20:24:08","slug":"powershell-ise-alias-to-command","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell-v2-0\/1324\/powershell-ise-alias-to-command\/","title":{"rendered":"PowerShell ISE Alias to Command"},"content":{"rendered":"<p>Earlier this week I <a href=\"http:\/\/jdhitsolutions.com\/blog\/2011\/04\/powershell-ise-case-closed\/\" target=\"_blank\">posted a function<\/a> 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.<!--more--><\/p>\n<p>My initial approach, which I use and you may still find useful, was to take a selected word in the ISE and convert it to either and alias or a command. Naturally assuming that the selected word is one or the other. So I came up with a single function that can be used two ways depending on which direction you need to go.<\/p>\n<p>[cc lang=\"PowerShell\"]<br \/>\nFunction Convert-AliasDefinition {<\/p>\n<p>[cmdletBinding(DefaultParameterSetName=\"ToDefinition\")]<\/p>\n<p>Param(<br \/>\n[Parameter(Position=0,Mandatory=$True,HelpMessage=\"Enter a string to convert\")]<br \/>\n[string]$Text,<br \/>\n[Parameter(ParameterSetName=\"ToAlias\")]<br \/>\n[switch]$ToAlias,<br \/>\n[Parameter(ParameterSetName=\"ToDefinition\")]<br \/>\n[switch]$ToDefinition<br \/>\n)<\/p>\n<p>#make sure we are using the ISE<br \/>\nif ($host.name -match \"ISE\")<br \/>\n{<br \/>\n    Try<br \/>\n    {<br \/>\n        #get alias if it exists otherwise throw an exception that<br \/>\n        #will be caught<br \/>\n        if ($ToAlias)<br \/>\n        {<br \/>\n            #get alias by definition and convert to name<br \/>\n            $alias=get-alias -definition $Text -ErrorAction Stop<br \/>\n            #there might be multiples so use the first one found<br \/>\n            if ($alias -is [array])<br \/>\n            {<br \/>\n                $replace=$alias[0].name<br \/>\n            }<br \/>\n            else<br \/>\n            {<br \/>\n                $replace=$alias.name<br \/>\n            }<br \/>\n        }<br \/>\n        else<br \/>\n        {<br \/>\n            #get alias by name and convert to definition<\/p>\n<p>            #if the text is ?, this is a special character so<br \/>\n            #we'll just assume it is Where-Object<br \/>\n            if ($Text -eq \"?\")<br \/>\n            {<br \/>\n                $Replace=\"Where-Object\"<br \/>\n            }<br \/>\n            else<br \/>\n            {<br \/>\n                $alias=get-alias -name $Text -ErrorAction Stop<br \/>\n                $replace=$alias.definition<br \/>\n            }<br \/>\n        } #Else ToDefinition<\/p>\n<p>    } #close Try<\/p>\n<p>    Catch<br \/>\n    {<br \/>\n        Write-Host \"Nothing for for $text\" -ForegroundColor Cyan<br \/>\n    }<\/p>\n<p>    Finally<br \/>\n    {<\/p>\n<p>        #make changes if an alias was found<br \/>\n        If ($replace)<br \/>\n        {<br \/>\n            #Insert the replacment<br \/>\n            $psise.currentfile.editor.insertText($replace)<br \/>\n        }<br \/>\n    }<br \/>\n} #if ISE<br \/>\nelse<br \/>\n{<br \/>\n    Write-Warning \"You must be using the PowerShell ISE\"<br \/>\n}<\/p>\n<p>} #end function<br \/>\n[\/cc]<\/p>\n<p>The Convert-AliasDefinition function will only work in the PowerShell ISE and assumes you want to replace selected text. I would trust that most of the time you need to convert from an alias to the full command name since aliases in scripts are frowned upon. The function uses parameter sets and a set of switch parameters. The default is to convert an alias to command. The code is really quite simple: invoke the Get-Alias cmdlet for the alias and get the definition property.<\/p>\n<p>[cc lang=\"PowerShell\"]<br \/>\n $alias=get-alias -name $Text -ErrorAction Stop<br \/>\n $replace=$alias.definition<br \/>\n[\/cc]<\/p>\n<p>When converting a command to an alias, the function takes the opposite approach.<\/p>\n<p>[cc lang=\"PowerShell\"]<br \/>\n $alias=get-alias -definition $Text -ErrorAction Stop<br \/>\n#there might be multiples so use the first one found<br \/>\nif ($alias -is [array])<br \/>\n{<br \/>\n   $replace=$alias[0].name<br \/>\n}<br \/>\n   else<br \/>\n{<br \/>\n  $replace=$alias.name<br \/>\n}<br \/>\n[\/cc]<\/p>\n<p>Because a command might have multiple aliases, I need to test if I got an array of aliases and if so I take the first one in the list.  One problem I ran into was trying to accommodate the ? alias for Where-Object. This is kind of a special character in PowerShell so I used a brute force approach.<\/p>\n<p>[cc lang=\"PowerShell\"]<br \/>\n #if the text is ?, this is a special character so<br \/>\n #we'll just assume it is Where-Object<br \/>\n if ($Text -eq \"?\")<br \/>\n {<br \/>\n     $Replace=\"Where-Object\"<br \/>\n }<br \/>\n[\/cc]<\/p>\n<p>Once I have the replacement string, it is a simple matter of using the ISE object model to insert the text back into the file. Because the word was hightlighted to begin with this has the effect of updating just the text.<\/p>\n<p>[cc lang=\"PowerShell\"]<br \/>\n#make changes if an alias was found<br \/>\nIf ($replace)<br \/>\n{<br \/>\n     #Insert the replacment<br \/>\n     $psise.currentfile.editor.insertText($replace)<br \/>\n}<br \/>\n[\/cc]<\/p>\n<p>To incorporate these changes into the ISE, I dot source the script file with the Convert-AliasDefiniton function in my ISE profile.<\/p>\n<p>[cc lang=\"PowerShell\"]<br \/>\n$psISE.CurrentPowerShellTab.AddOnsMenu.submenus.Add(\"Convert Selected to Alias\",{Convert-AliasDefinition $psise.CurrentFile.Editor.SelectedText -ToAlias},$Null) | Out-Null<br \/>\n$psISE.CurrentPowerShellTab.AddOnsMenu.submenus.Add(\"Convert Selected to Command\",{Convert-AliasDefinition $psise.CurrentFile.Editor.SelectedText -ToDefinition},$Null) | Out-Null<br \/>\n[\/cc]<\/p>\n<p>I didn't specify any keyboard shortcuts but you can if you wish. This will add two items to the Add-Ons menu. To use, I select an alias in my script, go to the menu, select Convert Selected to Command and presto chango the string is now a cmdlet name.  This should work for any aliases defined and visible from your ISE session.<\/p>\n<p>But, you may be asking, what about fixing an entire script?  That is a little more complicated and I'll save that for tomorrow. In the mean time you can download <a href='http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/04\/Convert-AliasDefinition.txt' target=\"_blank\">Convert-AliasDefinition<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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.<\/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,75],"tags":[160,224,232,534],"class_list":["post-1324","post","type-post","status-publish","format-standard","hentry","category-powershell-ise","category-powershell-v2-0","tag-alias","tag-function","tag-ise","tag-powershell"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PowerShell ISE Alias to Command &#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-v2-0\/1324\/powershell-ise-alias-to-command\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PowerShell ISE Alias to Command &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"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.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell-v2-0\/1324\/powershell-ise-alias-to-command\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2011-04-07T20:24:08+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=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-v2-0\\\/1324\\\/powershell-ise-alias-to-command\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-v2-0\\\/1324\\\/powershell-ise-alias-to-command\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"PowerShell ISE Alias to Command\",\"datePublished\":\"2011-04-07T20:24:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-v2-0\\\/1324\\\/powershell-ise-alias-to-command\\\/\"},\"wordCount\":739,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"keywords\":[\"Alias\",\"Function\",\"ISE\",\"PowerShell\"],\"articleSection\":[\"PowerShell ISE\",\"PowerShell v2.0\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-v2-0\\\/1324\\\/powershell-ise-alias-to-command\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-v2-0\\\/1324\\\/powershell-ise-alias-to-command\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-v2-0\\\/1324\\\/powershell-ise-alias-to-command\\\/\",\"name\":\"PowerShell ISE Alias to Command &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"datePublished\":\"2011-04-07T20:24:08+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-v2-0\\\/1324\\\/powershell-ise-alias-to-command\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-v2-0\\\/1324\\\/powershell-ise-alias-to-command\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-v2-0\\\/1324\\\/powershell-ise-alias-to-command\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell ISE\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell-ise\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PowerShell ISE Alias to Command\"}]},{\"@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 Alias to Command &#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-v2-0\/1324\/powershell-ise-alias-to-command\/","og_locale":"en_US","og_type":"article","og_title":"PowerShell ISE Alias to Command &#8226; The Lonely Administrator","og_description":"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.","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell-v2-0\/1324\/powershell-ise-alias-to-command\/","og_site_name":"The Lonely Administrator","article_published_time":"2011-04-07T20:24:08+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":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-v2-0\/1324\/powershell-ise-alias-to-command\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-v2-0\/1324\/powershell-ise-alias-to-command\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"PowerShell ISE Alias to Command","datePublished":"2011-04-07T20:24:08+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-v2-0\/1324\/powershell-ise-alias-to-command\/"},"wordCount":739,"commentCount":2,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"keywords":["Alias","Function","ISE","PowerShell"],"articleSection":["PowerShell ISE","PowerShell v2.0"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell-v2-0\/1324\/powershell-ise-alias-to-command\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-v2-0\/1324\/powershell-ise-alias-to-command\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell-v2-0\/1324\/powershell-ise-alias-to-command\/","name":"PowerShell ISE Alias to Command &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"datePublished":"2011-04-07T20:24:08+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-v2-0\/1324\/powershell-ise-alias-to-command\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell-v2-0\/1324\/powershell-ise-alias-to-command\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-v2-0\/1324\/powershell-ise-alias-to-command\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell ISE","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-ise\/"},{"@type":"ListItem","position":2,"name":"PowerShell ISE Alias to Command"}]},{"@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":1330,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell-v2-0\/1330\/powershell-ise-convert-all-aliases\/","url_meta":{"origin":1324,"position":0},"title":"PowerShell ISE Convert All Aliases","author":"Jeffery Hicks","date":"April 8, 2011","format":false,"excerpt":"Yesterday I posted an article on how to convert a selected word to an alias or cmdlet. While I think there is still some value in this piecemeal approach. sometimes you want to make wholesale changes, such as when troubleshooting a script that someone else wrote that is full of\u2026","rel":"","context":"In &quot;PowerShell v2.0&quot;","block_context":{"text":"PowerShell v2.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-v2-0\/"},"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":1324,"position":1},"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":1319,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell-ise\/1319\/powershell-ise-case-closed\/","url_meta":{"origin":1324,"position":2},"title":"PowerShell ISE Case Closed","author":"Jeffery Hicks","date":"April 5, 2011","format":false,"excerpt":"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\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":8709,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8709\/converting-powershell-scripts-to-functions\/","url_meta":{"origin":1324,"position":3},"title":"Converting PowerShell Scripts to Functions","author":"Jeffery Hicks","date":"December 10, 2021","format":false,"excerpt":"Recently, I shared some PowerShell code to export a function to a file. It was a popular post. My friend Richard Hicks (no relation) thought we was joking when he asked about converting files to functions. His thought was to take a bunch of PowerShell scripts, turn them into a\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\/12\/poc-modulecommands.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/12\/poc-modulecommands.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/12\/poc-modulecommands.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/12\/poc-modulecommands.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":3990,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3990\/friday-fun-creating-powershell-scripts-with-powershell\/","url_meta":{"origin":1324,"position":4},"title":"Friday Fun: Creating PowerShell Scripts with PowerShell","author":"Jeffery Hicks","date":"September 5, 2014","format":false,"excerpt":"Sometimes PowerShell really does seem like magic. Especially when you can use it to handle complicated or tedious tasks, such as creating a PowerShell script. I know many an IT Pro who want to script but without having to actually write a script. Well, I'm not sure that is realistic,\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"012914_1704_CreatingCIM1.png","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/01\/012914_1704_CreatingCIM1-150x150.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":4305,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4305\/what-powershell-script-was-i-working-on\/","url_meta":{"origin":1324,"position":5},"title":"What PowerShell Script Was I Working On?","author":"Jeffery Hicks","date":"March 24, 2015","format":false,"excerpt":"Last week I shared a script for finding recently modified files in a given directory. In fact, it wouldn't be that difficult to find the last files I was working on and open them in the PowerShell ISE. Assuming my Get-RecentFile function is loaded it is a simple as this:\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\/1324","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=1324"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1324\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=1324"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=1324"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=1324"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}