{"id":5488,"date":"2017-03-10T11:20:30","date_gmt":"2017-03-10T16:20:30","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=5488"},"modified":"2017-03-10T14:50:26","modified_gmt":"2017-03-10T19:50:26","slug":"adding-powershell-snippets-to-visual-studio-code","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/scripting\/5488\/adding-powershell-snippets-to-visual-studio-code\/","title":{"rendered":"Adding PowerShell Snippets to Visual Studio Code"},"content":{"rendered":"<p>So I've recently moved my daily work to a different laptop, a Yoga 900 with 16GB of RAM to be exact. I had been running Windows 8.1 but decided to jump in completely to a Windows 10 environment. As part of the process I've also made it a goal to begin using <a href=\"https:\/\/code.visualstudio.com\/\" target=\"_blank\">Visual Studio Code<\/a> (VS Code) for my PowerShell work. Like many of you I am heavily invested in the PowerShell ISE so I know this won't be easy. I've customized the PowerShell ISE extensively and have a lot of muscle memory that will need to be re-trained. One of the most important elements for me are snippets.<\/p>\n<p><!--more--><\/p>\n<p>I rely heavily on intellisense and my own snippets to increase my efficiency when working on a script project. Once you get Visual Studio Code installed, along with the PowerShell extension, there is a lot going for you out of the box. Tab completion and intellisense seems to be even more pervasive than in the PowerShell ISE. I suspect many of the snippets I used to rely on are no longer necessary in VS Code.<\/p>\n<p>But I still want to a few so here's how.<\/p>\n<p>All of the VS Code snippets are stored in language specific json files. In VS Code click on File - Preferences - User Snippets and start typing 'PowerShell'.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/03\/image.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/03\/image_thumb.png\" alt=\"image\" width=\"644\" height=\"263\" border=\"0\" \/><\/a><\/p>\n<p>Select PowerShell and hit Enter. This will open the default snippets file which is stored in $env:appdata\\code\\user\\snippets\\powershell.json.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/03\/image-1.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/03\/image_thumb-1.png\" alt=\"image\" width=\"644\" height=\"296\" border=\"0\" \/><\/a><\/p>\n<p>What you see is a comment describing what to insert.\u00a0 Move your cursor to above the closing curly brace and type the name for your snippet in quotes followed by a colon and open curly brace.<\/p>\n<pre class=\"lang:js mark:0 decode:true\">\"Quote\" : {\r\n<\/pre>\n<p>The snippet needs a <em>prefix<\/em> which will be the text you type to activate the snippet, a <em>body<\/em> and a <em>description<\/em>. End each line with a comma.<\/p>\n<pre class=\"lang:js mark:0 decode:true \">\"prefix\": \"psquote\",\r\n\"body\": \"# Those who forget to script are doomed to repeat their work.\",\r\n\"description\": \"my PowerShell quote\"\r\n<\/pre>\n<p>And end on the next line with a closing curly brace. The finished result should look like this:<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/03\/image-2.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/03\/image_thumb-2.png\" alt=\"image\" width=\"644\" height=\"130\" border=\"0\" \/><\/a><\/p>\n<p>Use Ctrl+S to save the file. Open a new file (Ctrl+N). By default this will be a plain text file.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/03\/image-3.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/03\/image_thumb-3.png\" alt=\"image\" width=\"644\" height=\"152\" border=\"0\" \/><\/a><\/p>\n<p>But if you click on the type you can change it to PowerShell. Now VS Code will apply all PowerShell-related features including the new snippet. Start typing the prefix:<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/03\/image-4.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/03\/image_thumb-4.png\" alt=\"image\" width=\"644\" height=\"129\" border=\"0\" \/><\/a><\/p>\n<p>Hit Enter and the snippet is inserted.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/03\/image-5.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/03\/image_thumb-5.png\" alt=\"image\" width=\"644\" height=\"93\" border=\"0\" \/><\/a><\/p>\n<p>Let's add another snippet.\u00a0 After the closing curly brace for the Quote snippet, type a comma and hit enter. Start the snippet on the next line.<\/p>\n<pre class=\"lang:js mark:0 decode:true \">\"Starting MyCommand\" : {\r\n    \"prefix\": \"startingps\",\r\n<\/pre>\n<p>I like using this line in my functions.<\/p>\n<pre class=\"lang:ps mark:0 decode:true \">Write-Verbose \"[$((Get-Date).TimeofDay) BEGIN] Starting $($myinvocation.mycommand)\"\r\n<\/pre>\n<p>But if I stick that line into the snippet file you'll see there is a problem. [Update: I realized I had a mistake in my code which I've since fixed, although the screen shots may show the \"bad\" code]<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/03\/image-6.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/03\/image_thumb-6.png\" alt=\"image\" width=\"644\" height=\"91\" border=\"0\" \/><\/a><\/p>\n<p>Red text is never good and there is a squiggle under the opening [.\u00a0 Json files can be tricky. The body value needs to be quoted as a string but I also need the verbose message to be inserted as a string with the double quotes so my variables expand. the trick is to escape those quote marks.<\/p>\n<pre class=\"lang:js mark:0 decode:true \">\"body\": \"Write-Verbose \\\"[$((Get-Date).TimeofDay) BEGIN] Starting $($myinvocation.mycommand.)\\\"\",\r\n<\/pre>\n<p>Save the PowerShell.json file, go back to the script and insert the 'startingps' snippet.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/03\/image-7.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/03\/image_thumb-7.png\" alt=\"image\" width=\"644\" height=\"94\" border=\"0\" \/><\/a><\/p>\n<p>Close -- but I didn't get the $ in front the mycommand variable. In VS Code snippets you can insert placeholders like $1 and $2. In the current state VS Code thinks I'm trying to do that when I really need the literal $. After some trial and error this seems to work.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/03\/image-8.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-width: 0px;\" title=\"image\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/03\/image_thumb-8.png\" alt=\"image\" width=\"644\" height=\"90\" border=\"0\" \/><\/a><\/p>\n<p>I inserted another $. Now when I save the file and insert the snippet it works as expected.<\/p>\n<p>My snippets so far have been one-liners. But often I (and you ) will want to insert multiple lines. The only thing you need to do differently is insert the body as an object between a set of square brackets, and end each line with a comma.<\/p>\n<pre class=\"lang:js mark:0 decode:true \">\"my Begin Block\" : {\r\n    \"prefix\": \"myBegin\",\r\n    \"body\": [\r\n    \"Begin {\",\r\n    \"\\tWrite-Verbose \\\"[$((Get-Date).TimeofDay) BEGIN] Starting $($$myinvocation.mycommand)\\\"\",\r\n    \"}\"\r\n    ],\r\n    \"description\": \"my standard begin block\"\r\n}\r\n<\/pre>\n<p>If you are paying close attention you'll also see \"\\t\" inserted before <a title=\"Read online help for this command\" href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkID=113429\" target=\"_blank\">Write-Verbose<\/a>. This will insert a single tab.<\/p>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/03\/image-9.png\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border: 0px;\" title=\"image\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/03\/image_thumb-9.png\" alt=\"image\" width=\"644\" height=\"123\" border=\"0\" \/><\/a><\/p>\n<p>If you need a blank line use\u00a0 \"\\r\".<\/p>\n<p>Sure, it may take a little time to get a snippet set up, but the point is that it is something you will use often and will pay for itself in no time.<\/p>\n<p>As I continue to explore VS Code I'll share my experiences either here on in the PowerShell section of <a href=\"https:\/\/www.petri.com\" target=\"_blank\">Petri.com<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So I&#8217;ve recently moved my daily work to a different laptop, a Yoga 900 with 16GB of RAM to be exact. I had been running Windows 8.1 but decided to jump in completely to a Windows 10 environment. As part of the process I&#8217;ve also made it a goal to begin using Visual Studio Code&#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: Adding #PowerShell Snippets to Visual Studio Code","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":[8],"tags":[534,464,526],"class_list":["post-5488","post","type-post","status-publish","format-standard","hentry","category-scripting","tag-powershell","tag-snippet","tag-vscode"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Adding PowerShell Snippets to Visual Studio Code &#8226; The Lonely Administrator<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/scripting\/5488\/adding-powershell-snippets-to-visual-studio-code\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Adding PowerShell Snippets to Visual Studio Code &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"So I&#039;ve recently moved my daily work to a different laptop, a Yoga 900 with 16GB of RAM to be exact. I had been running Windows 8.1 but decided to jump in completely to a Windows 10 environment. As part of the process I&#039;ve also made it a goal to begin using Visual Studio Code...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/scripting\/5488\/adding-powershell-snippets-to-visual-studio-code\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2017-03-10T16:20:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-03-10T19:50:26+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/03\/image_thumb.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=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/5488\\\/adding-powershell-snippets-to-visual-studio-code\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/5488\\\/adding-powershell-snippets-to-visual-studio-code\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Adding PowerShell Snippets to Visual Studio Code\",\"datePublished\":\"2017-03-10T16:20:30+00:00\",\"dateModified\":\"2017-03-10T19:50:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/5488\\\/adding-powershell-snippets-to-visual-studio-code\\\/\"},\"wordCount\":738,\"commentCount\":16,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/5488\\\/adding-powershell-snippets-to-visual-studio-code\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/03\\\/image_thumb.png\",\"keywords\":[\"PowerShell\",\"Snippet\",\"VSCode\"],\"articleSection\":[\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/5488\\\/adding-powershell-snippets-to-visual-studio-code\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/5488\\\/adding-powershell-snippets-to-visual-studio-code\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/5488\\\/adding-powershell-snippets-to-visual-studio-code\\\/\",\"name\":\"Adding PowerShell Snippets to Visual Studio Code &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/5488\\\/adding-powershell-snippets-to-visual-studio-code\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/5488\\\/adding-powershell-snippets-to-visual-studio-code\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/03\\\/image_thumb.png\",\"datePublished\":\"2017-03-10T16:20:30+00:00\",\"dateModified\":\"2017-03-10T19:50:26+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/5488\\\/adding-powershell-snippets-to-visual-studio-code\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/5488\\\/adding-powershell-snippets-to-visual-studio-code\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/5488\\\/adding-powershell-snippets-to-visual-studio-code\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/03\\\/image_thumb.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/03\\\/image_thumb.png\",\"width\":644,\"height\":263},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/5488\\\/adding-powershell-snippets-to-visual-studio-code\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Scripting\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/scripting\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Adding PowerShell Snippets to Visual Studio Code\"}]},{\"@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":"Adding PowerShell Snippets to Visual Studio Code &#8226; The Lonely Administrator","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/scripting\/5488\/adding-powershell-snippets-to-visual-studio-code\/","og_locale":"en_US","og_type":"article","og_title":"Adding PowerShell Snippets to Visual Studio Code &#8226; The Lonely Administrator","og_description":"So I've recently moved my daily work to a different laptop, a Yoga 900 with 16GB of RAM to be exact. I had been running Windows 8.1 but decided to jump in completely to a Windows 10 environment. As part of the process I've also made it a goal to begin using Visual Studio Code...","og_url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/5488\/adding-powershell-snippets-to-visual-studio-code\/","og_site_name":"The Lonely Administrator","article_published_time":"2017-03-10T16:20:30+00:00","article_modified_time":"2017-03-10T19:50:26+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/03\/image_thumb.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":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/5488\/adding-powershell-snippets-to-visual-studio-code\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/5488\/adding-powershell-snippets-to-visual-studio-code\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Adding PowerShell Snippets to Visual Studio Code","datePublished":"2017-03-10T16:20:30+00:00","dateModified":"2017-03-10T19:50:26+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/5488\/adding-powershell-snippets-to-visual-studio-code\/"},"wordCount":738,"commentCount":16,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/5488\/adding-powershell-snippets-to-visual-studio-code\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/03\/image_thumb.png","keywords":["PowerShell","Snippet","VSCode"],"articleSection":["Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/5488\/adding-powershell-snippets-to-visual-studio-code\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/5488\/adding-powershell-snippets-to-visual-studio-code\/","url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/5488\/adding-powershell-snippets-to-visual-studio-code\/","name":"Adding PowerShell Snippets to Visual Studio Code &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/5488\/adding-powershell-snippets-to-visual-studio-code\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/5488\/adding-powershell-snippets-to-visual-studio-code\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/03\/image_thumb.png","datePublished":"2017-03-10T16:20:30+00:00","dateModified":"2017-03-10T19:50:26+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/5488\/adding-powershell-snippets-to-visual-studio-code\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/5488\/adding-powershell-snippets-to-visual-studio-code\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/5488\/adding-powershell-snippets-to-visual-studio-code\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/03\/image_thumb.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/03\/image_thumb.png","width":644,"height":263},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/5488\/adding-powershell-snippets-to-visual-studio-code\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Scripting","item":"https:\/\/jdhitsolutions.com\/blog\/category\/scripting\/"},{"@type":"ListItem","position":2,"name":"Adding PowerShell Snippets to Visual Studio Code"}]},{"@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":5499,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5499\/more-fun-with-vscode-snippets\/","url_meta":{"origin":5488,"position":0},"title":"More Fun with VSCode Snippets","author":"Jeffery Hicks","date":"March 13, 2017","format":false,"excerpt":"A few days ago I posted an entry that explained how to create and use snippets in Visual Studio Code. As mentioned in that article I'm attempting to make the transition to VSCode for all my PowerShell work. Being able to use snippets is just one feature that I rely\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\/2017\/03\/image_thumb-10.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":3857,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3857\/dsc-resource-snippets\/","url_meta":{"origin":5488,"position":1},"title":"DSC Resource Snippets","author":"Jeffery Hicks","date":"May 23, 2014","format":false,"excerpt":"A few days ago I posted a PowerShell script that would generate a DSC configuration template. The idea was to generate all the code you might need and let you whittle it down to just what you need. On my primary system, I don't have any community or experimental DSC\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"talkbubble","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2011\/10\/talkbubble.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":7468,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7468\/powershell-7-scripting-with-the-powershell-ise\/","url_meta":{"origin":5488,"position":2},"title":"PowerShell 7 Scripting with the PowerShell ISE","author":"Jeffery Hicks","date":"May 11, 2020","format":false,"excerpt":"By now, everyone should have gotten the memo that with the move to PowerShell 7, the PowerShell ISE should be considered deprecated. When it comes to PowerShell script and module development for PowerShell 7, the recommended tool is Visual Studio Code. It is free and offers so much more than\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\/ise-ps7.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ise-ps7.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ise-ps7.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/05\/ise-ps7.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":5410,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5410\/creating-a-github-gist-with-powershell\/","url_meta":{"origin":5488,"position":3},"title":"Creating a Github Gist with PowerShell","author":"Jeffery Hicks","date":"January 26, 2017","format":false,"excerpt":"Recently I posted a PowerShell tool for creating a GitHub repository. In continuing my exploration of the GitHub API I wrote another PowerShell tool to create a GitHub gist. A gist is simple way to store and share snippets or code samples. I use them to share simple PowerShell scripts\u2026","rel":"","context":"In &quot;GitHub&quot;","block_context":{"text":"GitHub","link":"https:\/\/jdhitsolutions.com\/blog\/category\/github\/"},"img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/01\/image_thumb-18.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/01\/image_thumb-18.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2017\/01\/image_thumb-18.png?resize=525%2C300 1.5x"},"classes":[]},{"id":5073,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5073\/powershell-sessions-and-vs-code\/","url_meta":{"origin":5488,"position":4},"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":383,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/383\/primalforms-2009-script-editor\/","url_meta":{"origin":5488,"position":5},"title":"PrimalForms 2009 Script Editor","author":"Jeffery Hicks","date":"September 22, 2009","format":false,"excerpt":"SAPIEN\u2019s Primal Forms 2009 now has an integrated script editor that you can use as a standalone editor for PowerShell scripts. The app has integrated help, popup command help, a PowerShell browser, a .NET object browser. As you can see in the screen shot I\u2019ve started a very basic PowerShell\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"primalforms2009-script","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2009\/09\/primalforms2009script_thumb.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/5488","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=5488"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/5488\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=5488"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=5488"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=5488"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}