{"id":7350,"date":"2020-03-11T14:53:49","date_gmt":"2020-03-11T18:53:49","guid":{"rendered":"https:\/\/jdhitsolutions.com\/blog\/?p=7350"},"modified":"2020-03-11T14:53:49","modified_gmt":"2020-03-11T18:53:49","slug":"extending-external-scripts-in-powershell","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7350\/extending-external-scripts-in-powershell\/","title":{"rendered":"Extending External Scripts in PowerShell"},"content":{"rendered":"<p>I'm always looking for ways to do more with PowerShell. And often, once I find a technique, I look for other areas where I can apply it. I'm hoping that today might be like that for you. You may not have a need to duplicate my work in this article, but hopefully you'll recognize value in the techniques and concepts and find your own ways to apply them. What I am interested in is extending and improving PowerShell results.<\/p>\n<p>In PowerShell, there are different types of commands. One type is an ExternalScript. These are PowerShell script files that can be run <em>without<\/em> specifying the path.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7351\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external.png\" alt=\"get-external\" width=\"2400\" height=\"967\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external.png 2400w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-300x121.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-1024x413.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-768x309.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-1536x619.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-2048x825.png 2048w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-850x342.png 850w\" sizes=\"auto, (max-width: 2400px) 100vw, 2400px\" \/>Of course, there is more to the output.<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7352\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-profile.png\" alt=\"get-profile\" width=\"1556\" height=\"861\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-profile.png 1556w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-profile-300x166.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-profile-1024x567.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-profile-768x425.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-profile-1536x850.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-profile-850x470.png 850w\" sizes=\"auto, (max-width: 1556px) 100vw, 1556px\" \/>In short, this is just another file. As such I can get information.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">Get-Command profile.ps1 | \nSelect-Object -property Name,Path,@{Name=\"LastWriteTime\";Expression={(Get-Item $_.path).lastWriteTime}},\n@{Name=\"Location\";Expression={Split-Path $_.source}}\n<\/pre>\n<p>It is important that you follow the object in the pipeline. Get-Command is writing a System.Management.Automation.ExternalScriptInfo object to the pipeline. I already know some of the properties I can use.\u00a0 But I am also using a hashtable to define <em>new<\/em> properties. I'm creating a property called <em>LastWriteTime<\/em>. The value is the LastWriteTime value of the file object which I'm getting with Get-Item. I'm also creating a property called <em>Location<\/em> which will be the script's parent directory.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7354\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-profile-extended.png\" alt=\"get-profile-extended\" width=\"2337\" height=\"337\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-profile-extended.png 2337w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-profile-extended-300x43.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-profile-extended-1024x148.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-profile-extended-768x111.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-profile-extended-1536x221.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-profile-extended-2048x295.png 2048w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-profile-extended-850x123.png 850w\" sizes=\"auto, (max-width: 2337px) 100vw, 2337px\" \/>It is just as easy now to apply this to all external scripts.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">Get-Command -CommandType ExternalScript |Select-Object -property Name,Path,\n@{Name=\"LastWriteTime\";Expression={(Get-Item $_.path).lastWriteTime}},\n@{Name=\"Location\";Expression={Split-Path $_.source}} | \nSort-Object -Property Location |\nFormat-Table -GroupBy Location -property Name,LastWriteTime\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7355\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-2.png\" alt=\"get-external-2\" width=\"1202\" height=\"1360\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-2.png 1202w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-2-265x300.png 265w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-2-905x1024.png 905w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-2-768x869.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-2-300x339.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-2-850x962.png 850w\" sizes=\"auto, (max-width: 1202px) 100vw, 1202px\" \/><br \/>\nNow for the fun part. I want this type of information all the time. But I don't want to have to type out the custom hashtables. The solution is to add custom type extensions. And I can make this very easy.<\/p>\n<p>I'm going to use a command from my <a href=\"https:\/\/github.com\/jdhitsolutions\/PSTypeExtensionTools\" target=\"_blank\" rel=\"noopener noreferrer\">PSTypeExtensionTools<\/a>module which you can install from the PowerShell Gallery. It works in Windows PowerShell and PowerShell 7, even cross-platform. Here's my code.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">$tname = \"System.Management.Automation.ExternalScriptInfo\"\nAdd-PSTypeExtension -TypeName $tname -MemberType ScriptProperty -MemberName Location -Value {Split-Path $this.source}\nAdd-PSTypeExtension -TypeName $tname -MemberType ScriptProperty -MemberName Target -Value {\n    $f = Get-Item $this.source\n    #Use the target if the file is linked\n    if ($f.Target) {\n        $f.target\n    }\n    else {\n        #use the full name\n        $f.fullname\n    }\n}\nAdd-PSTypeExtension -TypeName $tname -MemberType ScriptProperty -MemberName LastWriteTime -Value {\n    $f = Get-Item $this.source\n    if ($f.Target) {\n        (Get-Item -path $f.target).LastWriteTime\n    }\n    else {\n        $f.LastWriteTime\n    }\n}\n<\/pre>\n<p>Yes, you can do something similar with Add-Member. But now see how easy my PowerShell command is.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7357\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-3.png\" alt=\"get-external-3\" width=\"2413\" height=\"1404\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-3.png 2413w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-3-300x175.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-3-1024x596.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-3-768x447.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-3-1536x894.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-3-2048x1192.png 2048w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-3-850x495.png 850w\" sizes=\"auto, (max-width: 2413px) 100vw, 2413px\" \/><\/p>\n<p>On my system, I have a few scripts with symlinks which is why I'm showing a Target property.<\/p>\n<p>These changes are only good in this PowerShell session. If I want them all the time, I'd have to insert the code into a profile script. However, I can simplify that\u00a0 because I can export my extensions to a json file.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">Get-PSTypeExtension -TypeName $tname | Export-PSTypeExtension -Path c:\\scripts\\externalscriptinfo.json\n<\/pre>\n<p>Then in my profile, I can have a single line of code to bring them in.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">Import-PSTypeExtension C:\\scripts\\externalscriptinfo.json\n<\/pre>\n<p>But wait...there's more! Remember that awkward command from earlier to format external scripts as a grouped table? I can simplify that as well.<br \/>\nIf you don't have it, install the <a href=\"https:\/\/github.com\/jdhitsolutions\/PSScriptTools\" target=\"_blank\" rel=\"noopener noreferrer\">PSScriptTools <\/a>module from the PowerShell Gallery. Then you can use the New-PSFormatXML command to create a custom formatting file.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">Get-Command mybackuppending.ps1 | New-PSFormatXML -Path c:\\scripts\\externalscriptinfo.format.ps1xml -Typename $tname -GroupBy Location -Properties Name, Target, LastWriteTime -ViewName location -FormatType table\n<\/pre>\n<p>In my PowerShell profile script I will import this file.<\/p>\n<pre class=\"lang:ps mark:0 decode:true\">Update-FormatData C:\\scripts\\externalscriptinfo.format.ps1xml\n<\/pre>\n<p>Look how easy this is now.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7359\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-formatted.png\" alt=\"get-external-formatted\" width=\"2375\" height=\"1371\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-formatted.png 2375w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-formatted-300x173.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-formatted-1024x591.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-formatted-768x443.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-formatted-1536x887.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-formatted-2048x1182.png 2048w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external-formatted-850x491.png 850w\" sizes=\"auto, (max-width: 2375px) 100vw, 2375px\" \/><br \/>\nI don't want to overwrite PowerShell's default view, but I can add my own. I love making PowerShell do what <em>I<\/em> need it to do. With just a little extra work I now have the information I need. In fact, I can already think of a few additions such as getting the file size and a new format view.<\/p>\n<p>I hope this inspires you to transform PowerShell to make your life and work easier. Good luck!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m always looking for ways to do more with PowerShell. And often, once I find a technique, I look for other areas where I can apply it. I&#8217;m hoping that today might be like that for you. You may not have a need to duplicate my work in this article, but hopefully you&#8217;ll recognize value&#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":"Jut published: Extending External Scripts in #PowerShell","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4],"tags":[534,256],"class_list":["post-7350","post","type-post","status-publish","format-standard","hentry","category-powershell","tag-powershell","tag-type-extensions"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Extending External Scripts in PowerShell &#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\/7350\/extending-external-scripts-in-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Extending External Scripts in PowerShell &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"I&#039;m always looking for ways to do more with PowerShell. And often, once I find a technique, I look for other areas where I can apply it. I&#039;m hoping that today might be like that for you. You may not have a need to duplicate my work in this article, but hopefully you&#039;ll recognize value...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/7350\/extending-external-scripts-in-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2020-03-11T18:53:49+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external.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=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7350\\\/extending-external-scripts-in-powershell\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7350\\\/extending-external-scripts-in-powershell\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Extending External Scripts in PowerShell\",\"datePublished\":\"2020-03-11T18:53:49+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7350\\\/extending-external-scripts-in-powershell\\\/\"},\"wordCount\":543,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7350\\\/extending-external-scripts-in-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/get-external.png\",\"keywords\":[\"PowerShell\",\"type extensions\"],\"articleSection\":[\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7350\\\/extending-external-scripts-in-powershell\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7350\\\/extending-external-scripts-in-powershell\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7350\\\/extending-external-scripts-in-powershell\\\/\",\"name\":\"Extending External Scripts in PowerShell &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7350\\\/extending-external-scripts-in-powershell\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7350\\\/extending-external-scripts-in-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/get-external.png\",\"datePublished\":\"2020-03-11T18:53:49+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7350\\\/extending-external-scripts-in-powershell\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7350\\\/extending-external-scripts-in-powershell\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7350\\\/extending-external-scripts-in-powershell\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/get-external.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/get-external.png\",\"width\":2400,\"height\":967},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7350\\\/extending-external-scripts-in-powershell\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Extending External Scripts in PowerShell\"}]},{\"@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":"Extending External Scripts in PowerShell &#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\/7350\/extending-external-scripts-in-powershell\/","og_locale":"en_US","og_type":"article","og_title":"Extending External Scripts in PowerShell &#8226; The Lonely Administrator","og_description":"I'm always looking for ways to do more with PowerShell. And often, once I find a technique, I look for other areas where I can apply it. I'm hoping that today might be like that for you. You may not have a need to duplicate my work in this article, but hopefully you'll recognize value...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7350\/extending-external-scripts-in-powershell\/","og_site_name":"The Lonely Administrator","article_published_time":"2020-03-11T18:53:49+00:00","og_image":[{"url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external.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":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7350\/extending-external-scripts-in-powershell\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7350\/extending-external-scripts-in-powershell\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Extending External Scripts in PowerShell","datePublished":"2020-03-11T18:53:49+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7350\/extending-external-scripts-in-powershell\/"},"wordCount":543,"commentCount":0,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7350\/extending-external-scripts-in-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external.png","keywords":["PowerShell","type extensions"],"articleSection":["PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/7350\/extending-external-scripts-in-powershell\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7350\/extending-external-scripts-in-powershell\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7350\/extending-external-scripts-in-powershell\/","name":"Extending External Scripts in PowerShell &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7350\/extending-external-scripts-in-powershell\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7350\/extending-external-scripts-in-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external.png","datePublished":"2020-03-11T18:53:49+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7350\/extending-external-scripts-in-powershell\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/7350\/extending-external-scripts-in-powershell\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7350\/extending-external-scripts-in-powershell\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/03\/get-external.png","width":2400,"height":967},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7350\/extending-external-scripts-in-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Extending External Scripts in PowerShell"}]},{"@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":4503,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4503\/updated-powershell-formatting-functions\/","url_meta":{"origin":7350,"position":0},"title":"Updated PowerShell Formatting Functions","author":"Jeffery Hicks","date":"August 19, 2015","format":false,"excerpt":"Last year I posted an article and a set of PowerShell functions to make it easier to format values. For some reason, I decided to revisit the functions and ended up revising and extending them. I modified Format-Value so that you can format a number as a currency or a\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":5850,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5850\/extending-powershell-datetime-objects\/","url_meta":{"origin":7350,"position":1},"title":"Extending PowerShell DateTime Objects","author":"Jeffery Hicks","date":"December 28, 2017","format":false,"excerpt":"I've been experimenting more with my PSTypeExtensionTools module, finding more objects to enhance.\u00a0 You can check out the project on Github and install the module from the PowerShell Gallery. My current fun has been with the DateTime object \u2013 specifically converting a value into another culture.\u00a0 Apparently those of us\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\/2017\/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\/2017\/12\/image_thumb-13.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/12\/image_thumb-13.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":6629,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6629\/extending-powershell-and-docker-containers\/","url_meta":{"origin":7350,"position":2},"title":"Extending PowerShell and Docker Containers","author":"Jeffery Hicks","date":"April 2, 2019","format":false,"excerpt":"I've been continuing to tinker with my PowerShell command for getting information about Docker containers. The Docker CLI is fine, but it is very difficult to work with the output or do much with it. That's why I prefer to have objects in a PowerShell pipeline. One of the Docker\u2026","rel":"","context":"In &quot;Docker&quot;","block_context":{"text":"Docker","link":"https:\/\/jdhitsolutions.com\/blog\/category\/docker\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/04\/image_thumb-6.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/04\/image_thumb-6.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/04\/image_thumb-6.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/04\/image_thumb-6.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":5761,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5761\/extending-powershell-with-custom-property-sets\/","url_meta":{"origin":7350,"position":3},"title":"Extending PowerShell with Custom Property Sets","author":"Jeffery Hicks","date":"November 8, 2017","format":false,"excerpt":"If you've been following along on the blog recently you've read about my use of PowerShell type extensions. This is a way of adding new properties to things I use all the time. The goal is to save typing and get what I need with minimal effort. You can also\u2026","rel":"","context":"In &quot;Hyper-V&quot;","block_context":{"text":"Hyper-V","link":"https:\/\/jdhitsolutions.com\/blog\/category\/hyper-v\/"},"img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/11\/image_thumb-7.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/11\/image_thumb-7.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/11\/image_thumb-7.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/11\/image_thumb-7.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":8499,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8499\/using-the-powershell-ise-as-a-remote-management-console\/","url_meta":{"origin":7350,"position":4},"title":"Using the PowerShell ISE as a Remote Management Console","author":"Jeffery Hicks","date":"July 20, 2021","format":false,"excerpt":"Way back before the days of PowerShell Core, or even VS Code for that matter, the PowerShell ISE was the center of my PowerShell world. I spent a lot of time finding ways to make it easier for me to use and to push it to its limits. Naturally, the\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\/07\/ise-remotetab-form2.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1931,"url":"https:\/\/jdhitsolutions.com\/blog\/miscellaneous\/1931\/thursday-treat-a-powershell-word-find-game\/","url_meta":{"origin":7350,"position":5},"title":"Thursday Treat &#8211; A PowerShell Word Find Game","author":"Jeffery Hicks","date":"December 29, 2011","format":false,"excerpt":"Now for something completely different but hopefully a little fun. I'm a big fan of word games and puzzles. Tim Bolton has assembled a few PowerShell themed crosswords, which you can find on his blog. I've always like word finds so I put together a pretty simple one using 16\u2026","rel":"","context":"In &quot;Miscellaneous&quot;","block_context":{"text":"Miscellaneous","link":"https:\/\/jdhitsolutions.com\/blog\/category\/miscellaneous\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/12\/PSWordFind-1-300x275.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/7350","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=7350"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/7350\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=7350"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=7350"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=7350"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}