{"id":7931,"date":"2020-12-07T10:14:54","date_gmt":"2020-12-07T15:14:54","guid":{"rendered":"https:\/\/jdhitsolutions.com\/blog\/?p=7931"},"modified":"2020-12-07T10:14:57","modified_gmt":"2020-12-07T15:14:57","slug":"extracting-icons-with-powershell","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7931\/extracting-icons-with-powershell\/","title":{"rendered":"Extracting Icons with PowerShell"},"content":{"rendered":"\n<p>Last week I was seeing what else I could add to my Windows Terminal setup. If you can launch a console from the command line, you can probably create a Windows Terminal profile for it. Recently, I've added Ruby and Python to my desktop, both of which have interactive consoles. I thought, \"Why not add them to Windows Terminal?\"<\/p>\n\n\n\n<p>I looked at the properties for the Ruby console and copied and command line. With this, it was easy enough to add a new profile.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"json\" class=\"language-json\">{\n    \/\/ Ruby cmd\n    \"guid\" :\"{a7849c4a-db74-4723-adf2-c717357f0a1a}\",\n    \"name\" : \"Ruby\",\n    \"commandline\": \"C:\\\\Windows\\\\System32\\\\cmd.exe \/E:ON \/K C:\\\\Ruby27-x64\\\\bin\\\\setrbvars.cmd\",\n    \"tabTitle\": \"Ruby Cmd\"\n},<\/code><\/pre>\n\n\n\n<p>What I didn't have was an icon, but the ruby.exe file did. I needed a PowerShell way to extract the icon and save it to a file. There are plenty of third-party tools that will handle this task, but where's fun in that? I poked around looking for a starting point and came across an old piece of code from <a href=\"https:\/\/duffney.io\/\" target=\"_blank\" rel=\"noreferrer noopener\">Josh Duffney<\/a> posted on <a href=\"https:\/\/community.spiceworks.com\/topic\/592770-extract-icon-from-exe-powershell\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Spiceworks<\/a>. His code had the key bit I needed, the necessary .NET Framework class and command to extract the icon.<\/p>\n\n\n\n<p>With this inspiration, I wrote this PowerShell script.<\/p>\n\n\n\n<pre class=\"wp-block-code\" title=\"Extract-Icon.ps1\"><code lang=\"powershell\" class=\"language-powershell\">#requires -version 5.1\n\n# inspired by https:\/\/community.spiceworks.com\/topic\/592770-extract-icon-from-exe-powershell\n\n[CmdletBinding(SupportsShouldProcess)]\nParam(\n    [Parameter(Position = 0, Mandatory,HelpMessage = \"Specify the path to the file.\")]\n    [ValidateScript({Test-Path $_})]\n    [string]$Path,\n\n    [Parameter(HelpMessage = \"Specify the folder to save the file.\")]\n    [ValidateScript({Test-Path $_})]\n    [string]$Destination = \".\",\n\n    [parameter(HelpMessage = \"Specify an alternate base name for the new image file. Otherwise, the source name will be used.\")]\n    [ValidateNotNullOrEmpty()]\n    [string]$Name,\n\n    [Parameter(HelpMessage = \"What format do you want to use? The default is png.\")]\n    [ValidateSet(\"ico\",\"bmp\",\"png\",\"jpg\",\"gif\")]\n    [string]$Format = \"png\"\n    )\n\n    Write-Verbose \"Starting $($MyInvocation.MyCommand)\"\n\n    Try {\n        Add-Type -AssemblyName System.Drawing -ErrorAction Stop\n    }\n    Catch {\n        Write-Warning \"Failed to import System.Drawing\"\n        Throw $_\n    }\n\n    Switch ($format) {\n        \"ico\" {$ImageFormat = \"icon\"}\n        \"bmp\" {$ImageFormat = \"Bmp\"}\n        \"png\" {$ImageFormat = \"Png\"}\n        \"jpg\" {$ImageFormat = \"Jpeg\"}\n        \"gif\" {$ImageFormat = \"Gif\"}\n    }\n\n    $file = Get-Item $path\n    Write-Verbose \"Processing $($file.fullname)\"\n    #convert destination to file system path\n    $Destination = Convert-Path -path $Destination\n\n    if ($Name) {\n        $base = $Name\n    }\n    else {\n        $base = $file.BaseName\n    }\n\n    #construct the image file name\n    $out = Join-Path -Path $Destination -ChildPath \"$base.$format\"\n\n    Write-Verbose \"Extracting $ImageFormat image to $out\"\n    $ico =  [System.Drawing.Icon]::ExtractAssociatedIcon($file.FullName)\n\n    if ($ico) {\n        #WhatIf (target, action)\n        if ($PSCmdlet.ShouldProcess($out, \"Extract icon\")) {\n            $ico.ToBitmap().Save($Out,$Imageformat)\n            Get-Item -path $out\n        }\n    }\n    else {\n        #this should probably never get called\n        Write-Warning \"No associated icon image found in $($file.fullname)\"\n    }\n\n    Write-Verbose \"Ending $($MyInvocation.MyCommand)\"\n<\/code><\/pre>\n\n\n\n<p>The script will extract the icon from the file specified by the Path parameter and save it in the specified format. There are other formats, but I decided on a ValidateSet() attribute with the most likely formats. The script will create an output file name based on the destination and original file name. Or, you can specify an alternate base name. I also added support for -WhatIf.<\/p>\n\n\n\n<p>With this script, I can run a command like this to extract the icon.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"111\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/extract-1024x111.png\" alt=\"extracting icon whatit\" class=\"wp-image-7932\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/extract-1024x111.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/extract-300x33.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/extract-768x83.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/extract-1536x167.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/extract-2048x223.png 2048w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/extract-850x92.png 850w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>That looks good. I'll re-run without -WhatIf to extract the icon.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"32\" height=\"32\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/ruby.png\" alt=\"ruby icon\" class=\"wp-image-7933\"\/><\/figure>\n\n\n\n<p>Now, I can update my Windows Terminal setting.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"json\" class=\"language-json\">{\n    \/\/ Ruby cmd\n    \"guid\" :\"{a7849c4a-db74-4723-adf2-c717357f0a1a}\",\n    \"name\" : \"Ruby\",\n    \"commandline\": \"C:\\\\Windows\\\\System32\\\\cmd.exe \/E:ON \/K C:\\\\Ruby27-x64\\\\bin\\\\setrbvars.cmd\",\n    \"tabTitle\": \"Ruby Cmd\",\n    \"icon\": \"d:\\\\onedrive\\\\windowsterminal\\\\profileicons\\\\ruby.png\"\n},<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"819\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/ruby-profile-1024x819.png\" alt=\"ruby Windows Terminal session\" class=\"wp-image-7934\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/ruby-profile-1024x819.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/ruby-profile-300x240.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/ruby-profile-768x614.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/ruby-profile-850x680.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/ruby-profile.png 1309w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>I can do the same thing with Python.exe.<\/p>\n\n\n\n<p>I hope you find this useful. You could easily turn it into a function. Comments and questions are always welcome.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last week I was seeing what else I could add to my Windows Terminal setup. If you can launch a console from the command line, you can probably create a Windows Terminal profile for it. Recently, I&#8217;ve added Ruby and Python to my desktop, both of which have interactive consoles. I thought, &#8220;Why not add&#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":"New on the blog: Extracting Icons with #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":[540],"class_list":["post-7931","post","type-post","status-publish","format-standard","hentry","category-powershell","tag-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Extracting Icons with PowerShell &#8226; The Lonely Administrator<\/title>\n<meta name=\"description\" content=\"Here is an easy to use PowerShell script to extract an icon from a file. This can be helpful when creating new Windows Terminal profiles.\" \/>\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\/7931\/extracting-icons-with-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Extracting Icons with PowerShell &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"Here is an easy to use PowerShell script to extract an icon from a file. This can be helpful when creating new Windows Terminal profiles.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/7931\/extracting-icons-with-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2020-12-07T15:14:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-12-07T15:14:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/extract-1024x111.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\\\/7931\\\/extracting-icons-with-powershell\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7931\\\/extracting-icons-with-powershell\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Extracting Icons with PowerShell\",\"datePublished\":\"2020-12-07T15:14:54+00:00\",\"dateModified\":\"2020-12-07T15:14:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7931\\\/extracting-icons-with-powershell\\\/\"},\"wordCount\":314,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7931\\\/extracting-icons-with-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/extract-1024x111.png\",\"keywords\":[\"Scripting\"],\"articleSection\":[\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7931\\\/extracting-icons-with-powershell\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7931\\\/extracting-icons-with-powershell\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7931\\\/extracting-icons-with-powershell\\\/\",\"name\":\"Extracting Icons with PowerShell &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7931\\\/extracting-icons-with-powershell\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7931\\\/extracting-icons-with-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/extract-1024x111.png\",\"datePublished\":\"2020-12-07T15:14:54+00:00\",\"dateModified\":\"2020-12-07T15:14:57+00:00\",\"description\":\"Here is an easy to use PowerShell script to extract an icon from a file. This can be helpful when creating new Windows Terminal profiles.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7931\\\/extracting-icons-with-powershell\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7931\\\/extracting-icons-with-powershell\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7931\\\/extracting-icons-with-powershell\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/extract.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/extract.png\",\"width\":3303,\"height\":359},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/7931\\\/extracting-icons-with-powershell\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Extracting Icons with 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":"Extracting Icons with PowerShell &#8226; The Lonely Administrator","description":"Here is an easy to use PowerShell script to extract an icon from a file. This can be helpful when creating new Windows Terminal profiles.","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\/7931\/extracting-icons-with-powershell\/","og_locale":"en_US","og_type":"article","og_title":"Extracting Icons with PowerShell &#8226; The Lonely Administrator","og_description":"Here is an easy to use PowerShell script to extract an icon from a file. This can be helpful when creating new Windows Terminal profiles.","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7931\/extracting-icons-with-powershell\/","og_site_name":"The Lonely Administrator","article_published_time":"2020-12-07T15:14:54+00:00","article_modified_time":"2020-12-07T15:14:57+00:00","og_image":[{"url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/extract-1024x111.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\/7931\/extracting-icons-with-powershell\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7931\/extracting-icons-with-powershell\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Extracting Icons with PowerShell","datePublished":"2020-12-07T15:14:54+00:00","dateModified":"2020-12-07T15:14:57+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7931\/extracting-icons-with-powershell\/"},"wordCount":314,"commentCount":1,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7931\/extracting-icons-with-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/extract-1024x111.png","keywords":["Scripting"],"articleSection":["PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/7931\/extracting-icons-with-powershell\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7931\/extracting-icons-with-powershell\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7931\/extracting-icons-with-powershell\/","name":"Extracting Icons with PowerShell &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7931\/extracting-icons-with-powershell\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7931\/extracting-icons-with-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/extract-1024x111.png","datePublished":"2020-12-07T15:14:54+00:00","dateModified":"2020-12-07T15:14:57+00:00","description":"Here is an easy to use PowerShell script to extract an icon from a file. This can be helpful when creating new Windows Terminal profiles.","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7931\/extracting-icons-with-powershell\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/7931\/extracting-icons-with-powershell\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7931\/extracting-icons-with-powershell\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/extract.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/extract.png","width":3303,"height":359},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7931\/extracting-icons-with-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Extracting Icons with 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":6800,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6800\/a-powershell-proof-of-concept-with-windows-terminal\/","url_meta":{"origin":7931,"position":0},"title":"A PowerShell Proof of Concept with Windows Terminal","author":"Jeffery Hicks","date":"July 8, 2019","format":false,"excerpt":"I recently updated my Windows 10 systems to the 1903 release. One of the reasons is that I wanted to try out the new Windows Terminal preview. You can find it in the Windows Store. This is bleeding edge stuff and far from complete but promises to be a great\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\/07\/image_thumb.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/07\/image_thumb.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/07\/image_thumb.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":5073,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5073\/powershell-sessions-and-vs-code\/","url_meta":{"origin":7931,"position":1},"title":"PowerShell Sessions and VS Code","author":"Jeffery Hicks","date":"June 8, 2016","format":false,"excerpt":"If you do any amount of PowerShell scripting you have most likely heard about Visual Studio Code. This is a free cross-platform light-weight editor from Microsoft. VS Code supports multiple languages and is extensible. I've tried different versions since it was first released but never found a reason to jump\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/06\/image_thumb-5.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/06\/image_thumb-5.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/06\/image_thumb-5.png?resize=525%2C300 1.5x"},"classes":[]},{"id":6887,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/6887\/creating-a-spooky-windows-terminal-theme\/","url_meta":{"origin":7931,"position":2},"title":"Creating a Spooky Windows Terminal Theme","author":"Jeffery Hicks","date":"October 29, 2019","format":false,"excerpt":"With Halloween fast arriving, I thought I'd share some more holiday-themed fun. Today's entry isn't necessarily PowerShell related but you might use it with your PowerShell work. If you've been kicking the tires on the Windows Terminal project from Microsoft, you might enjoy this. Here's the finished product and then\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\/10\/image_thumb-10.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/10\/image_thumb-10.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/10\/image_thumb-10.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2019\/10\/image_thumb-10.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":7476,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7476\/open-windows-terminal-powershell-split-paned\/","url_meta":{"origin":7931,"position":3},"title":"Open Windows Terminal PowerShell Split Paned","author":"Jeffery Hicks","date":"May 14, 2020","format":false,"excerpt":"The other night I presented for the Mississippi PowerShell User Group on how to get started using Windows Terminal. This has been my go-to PowerShell console for quite a while. I use Windows Terminal for everything. During the talk a question came up about starting a session with split panes.\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\/2020\/05\/wt-split.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/wt-split.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/wt-split.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/wt-split.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/wt-split.png?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":7242,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7242\/powershell-remoting-profiles-with-windows-terminal\/","url_meta":{"origin":7931,"position":4},"title":"PowerShell Remoting Profiles with Windows Terminal","author":"Jeffery Hicks","date":"February 10, 2020","format":false,"excerpt":"I have jumped in the deep end and fully committed to Windows Terminal as my default PowerShell environment. I love having one interface with tabs for different terminal profiles. Windows Terminal makes it easy for me to have tabs open to PowerShell 7, Windows PowerShell, an Ubuntu instance or even\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\/2020\/02\/image_thumb-8.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/02\/image_thumb-8.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/02\/image_thumb-8.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/02\/image_thumb-8.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":8666,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/8666\/friday-fun-powershell-console-editing\/","url_meta":{"origin":7931,"position":5},"title":"Friday Fun: PowerShell Console Editing","author":"Jeffery Hicks","date":"October 29, 2021","format":false,"excerpt":"The other day I read an interesting article on Adam Bertram's blog about editing files with a text editor in PowerShell. Naturally, the PowerShell wheels in my head began turning. While I was intrigued by some of the options in the article, I've in fact installed the Micro editor to\u2026","rel":"","context":"In &quot;Scripting&quot;","block_context":{"text":"Scripting","link":"https:\/\/jdhitsolutions.com\/blog\/category\/scripting\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/10\/nano-verbose.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/10\/nano-verbose.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/10\/nano-verbose.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/10\/nano-verbose.png?resize=700%2C400&ssl=1 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/7931","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=7931"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/7931\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=7931"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=7931"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=7931"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}