{"id":8777,"date":"2022-01-11T10:42:46","date_gmt":"2022-01-11T15:42:46","guid":{"rendered":"https:\/\/jdhitsolutions.com\/blog\/?p=8777"},"modified":"2022-01-11T10:42:49","modified_gmt":"2022-01-11T15:42:49","slug":"copy-powershell-history-command","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8777\/copy-powershell-history-command\/","title":{"rendered":"Copy PowerShell History Command"},"content":{"rendered":"\n<p>I thought I'd share a short but useful PowerShell utility. This is something that is very handy when I am writing. As you know, PowerShell maintains a command history in your PowerShell session. You can view history with the Get-History cmdlet or its alias <em>h<\/em>. To re-rerun a command use Invoke-History or its alias <em>r<\/em>, specifying the history ID. You can also use PSReadline and Ctrl+R to search history. An advantage with this approach is that you are technically searching your saved history which can include commands from previous sessions. I use this all the time but sometimes, I have slightly different needs. That's where today's function comes into play.<\/p>\n\n\n\n<p>There are many times when I want the command line from a history item. Run this to see what I'm talking about.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Get-History | Select ID,Commandline<\/code><\/pre>\n\n\n\n<p>I either need to copy the command line so I can paste it into a document or I want to bring it back to my prompt to either re-run or edit and then run. Running Invoke-History is simple enough for re-running the command, but I can't tweak it. Or I can use PSReadline and search for the command. Once I find it, I can adjust it and then run it. But I need something in-between. The answer is a utility to copy the command line from the specified history item to the clipboard. Lee Holmes has a similar utility described in the PowerShell Cookbook. This is my version.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Function Copy-HistoryCommand {\n\n    [CmdletBinding(SupportsShouldProcess)]\n    [alias(\"ch\")]\n    [outputtype(\"None\", \"System.String\")]\n    Param(\n        [Parameter(Position = 0)]\n        [ValidateNotNullOrEmpty()]\n        [int]$ID = $(Get-History).Count,\n        [switch]$Passthru)\n\n    Begin {\n        Write-Verbose \"[BEGIN  ] Starting: $($MyInvocation.Mycommand)\"\n    } #begin\n\n    Process {\n        Write-Verbose \"[PROCESS] Getting commandline from history item: $id\"\n        $cmdstring = (Get-History -Id $id).CommandLine\n        If ($PSCmdlet.ShouldProcess(\"ID #$id [$cmdstring]\")) {\n            $cmdstring | Microsoft.PowerShell.Management\\Set-Clipboard\n\n            If ($Passthru) {\n                #write the command to the pipeline\n                $cmdstring\n            } #If passthru\n        }\n    } #process\n\n    End {\n        Write-Verbose \"[END    ] Ending: $($MyInvocation.Mycommand)\"\n    } #end\n\n} #close function<\/code><\/pre>\n\n\n\n<p>The command is pretty simple. It takes the commandline property and copies it to the clipboard using Set-Clipboard. The function merely makes this easier by defining an alias and adding a few features like -Passthru and -WhatIf.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/ch.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"587\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/ch-1024x587.png\" alt=\"copy history command\" class=\"wp-image-8778\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/ch-1024x587.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/ch-300x172.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/ch-768x441.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/ch-1536x881.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/ch-850x488.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/ch.png 1961w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>In this example, I'm copying the command from history item #3 to the clipboard. I used -Passthru so you can see for yourself. In my Windows Terminal session, I can use Ctrl+V or the right mouse button to paste the command at my prompt. That's what I love about this. It only takes a few simple keystrokes to bring back a command I want to edit and re-run. I haven't found a way to copy the command and automatically paste it into the next prompt. But the current process is simple and quick enough.<\/p>\n\n\n\n<p>This command will eventually be part of the <a href=\"https:\/\/github.com\/jdhitsolutions\/PSScriptTools\" target=\"_blank\" rel=\"noreferrer noopener\">PSScriptTools <\/a>module. But for now, feel free to use this code if this is something you would find useful.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I thought I&#8217;d share a short but useful PowerShell utility. This is something that is very handy when I am writing. As you know, PowerShell maintains a command history in your PowerShell session. You can view history with the Get-History cmdlet or its alias h. To re-rerun a command use Invoke-History or its alias r,&#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: Copying #PowerShell History Commands ","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,8],"tags":[224,244,534],"class_list":["post-8777","post","type-post","status-publish","format-standard","hentry","category-powershell","category-scripting","tag-function","tag-history","tag-powershell"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Copy PowerShell History Command &#8226; The Lonely Administrator<\/title>\n<meta name=\"description\" content=\"Here&#039;s a simple PowerShell function I use to quickly copy a history command line to the clipboard. This is a fast alternative to PSReadline.\" \/>\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\/8777\/copy-powershell-history-command\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Copy PowerShell History Command &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"Here&#039;s a simple PowerShell function I use to quickly copy a history command line to the clipboard. This is a fast alternative to PSReadline.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/8777\/copy-powershell-history-command\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2022-01-11T15:42:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-01-11T15:42:49+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/ch-1024x587.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\\\/8777\\\/copy-powershell-history-command\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8777\\\/copy-powershell-history-command\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Copy PowerShell History Command\",\"datePublished\":\"2022-01-11T15:42:46+00:00\",\"dateModified\":\"2022-01-11T15:42:49+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8777\\\/copy-powershell-history-command\\\/\"},\"wordCount\":411,\"commentCount\":8,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8777\\\/copy-powershell-history-command\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/ch-1024x587.png\",\"keywords\":[\"Function\",\"History\",\"PowerShell\"],\"articleSection\":[\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8777\\\/copy-powershell-history-command\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8777\\\/copy-powershell-history-command\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8777\\\/copy-powershell-history-command\\\/\",\"name\":\"Copy PowerShell History Command &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8777\\\/copy-powershell-history-command\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8777\\\/copy-powershell-history-command\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/ch-1024x587.png\",\"datePublished\":\"2022-01-11T15:42:46+00:00\",\"dateModified\":\"2022-01-11T15:42:49+00:00\",\"description\":\"Here's a simple PowerShell function I use to quickly copy a history command line to the clipboard. This is a fast alternative to PSReadline.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8777\\\/copy-powershell-history-command\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8777\\\/copy-powershell-history-command\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8777\\\/copy-powershell-history-command\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/ch.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/01\\\/ch.png\",\"width\":1961,\"height\":1125},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/8777\\\/copy-powershell-history-command\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Copy PowerShell History Command\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Copy PowerShell History Command &#8226; The Lonely Administrator","description":"Here's a simple PowerShell function I use to quickly copy a history command line to the clipboard. This is a fast alternative to PSReadline.","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\/8777\/copy-powershell-history-command\/","og_locale":"en_US","og_type":"article","og_title":"Copy PowerShell History Command &#8226; The Lonely Administrator","og_description":"Here's a simple PowerShell function I use to quickly copy a history command line to the clipboard. This is a fast alternative to PSReadline.","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8777\/copy-powershell-history-command\/","og_site_name":"The Lonely Administrator","article_published_time":"2022-01-11T15:42:46+00:00","article_modified_time":"2022-01-11T15:42:49+00:00","og_image":[{"url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/ch-1024x587.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\/8777\/copy-powershell-history-command\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8777\/copy-powershell-history-command\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Copy PowerShell History Command","datePublished":"2022-01-11T15:42:46+00:00","dateModified":"2022-01-11T15:42:49+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8777\/copy-powershell-history-command\/"},"wordCount":411,"commentCount":8,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8777\/copy-powershell-history-command\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/ch-1024x587.png","keywords":["Function","History","PowerShell"],"articleSection":["PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/8777\/copy-powershell-history-command\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8777\/copy-powershell-history-command\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8777\/copy-powershell-history-command\/","name":"Copy PowerShell History Command &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8777\/copy-powershell-history-command\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8777\/copy-powershell-history-command\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/ch-1024x587.png","datePublished":"2022-01-11T15:42:46+00:00","dateModified":"2022-01-11T15:42:49+00:00","description":"Here's a simple PowerShell function I use to quickly copy a history command line to the clipboard. This is a fast alternative to PSReadline.","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8777\/copy-powershell-history-command\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/8777\/copy-powershell-history-command\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8777\/copy-powershell-history-command\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/ch.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/ch.png","width":1961,"height":1125},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8777\/copy-powershell-history-command\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},{"@type":"ListItem","position":2,"name":"Copy PowerShell History Command"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":1567,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1567\/friday-fun-re-run-last-command\/","url_meta":{"origin":8777,"position":0},"title":"Friday Fun Re-Run Last Command","author":"Jeffery Hicks","date":"July 29, 2011","format":false,"excerpt":"Ok, I'll be the first to admit you might not find a production use for this tip, but that's what makes it fun. Interactively, you can always hit the up arrow to get the last command in your command buffer. But what if you are running a script and for\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":1191,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1191\/get-variable-definition\/","url_meta":{"origin":8777,"position":1},"title":"Get Variable Definition","author":"Jeffery Hicks","date":"March 7, 2011","format":false,"excerpt":"Last week a question came across my email about how to find out where a variable came from. I thought this was a great question because I've run into this scenario as well. I see a variable but don't recall what command I typed to create it. What I need\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":2787,"url":"https:\/\/jdhitsolutions.com\/blog\/friday-fun\/2787\/friday-fun-a-graphical-powershell-history-picker\/","url_meta":{"origin":8777,"position":2},"title":"Friday Fun A Graphical PowerShell History Picker","author":"Jeffery Hicks","date":"February 8, 2013","format":false,"excerpt":"One of my favorite features in PowerShell 3.0 is that you can select items in Out-Gridview which will then pipe the object back to the pipeline. One way I've been using this is as graphical \"picker\" for command history. I use Get-History, actually its alias h, all the time. Once\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"history-picker","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/02\/history-picker-300x230.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":3918,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/3918\/pimp-your-prompt\/","url_meta":{"origin":8777,"position":3},"title":"Pimp your Prompt","author":"Jeffery Hicks","date":"July 16, 2014","format":false,"excerpt":"If you are like me and live in PowerShell, then you spend a great deal of your day looking at your PowerShell prompt. That little indicator in the console and ISE that usually shows where you are. That little part of your PowerShell world is defined by a built-in function\u2026","rel":"","context":"In &quot;Powershell 3.0&quot;","block_context":{"text":"Powershell 3.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-3-0\/"},"img":{"alt_text":"bling2","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/07\/bling2-150x150.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1046,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1046\/convert-history-to-script\/","url_meta":{"origin":8777,"position":4},"title":"Convert History to Script","author":"Jeffery Hicks","date":"January 12, 2011","format":false,"excerpt":"Whenever I teach or speak about PowerShell, a recurring mantra is that there is no difference between running a PowerShell script and executing commands interactively in the shell, except that it saves you typing. You can create a PowerShell script by simply copying and pasting commands from the shell into\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":8969,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8969\/powershell-predicting-with-style\/","url_meta":{"origin":8777,"position":5},"title":"PowerShell Predicting with Style","author":"Jeffery Hicks","date":"March 28, 2022","format":false,"excerpt":"I've been using the PSReadline module for years in PowerShell. I especially loved it when the module added inline command prediction based on your history. You would start typing a command and the module would search your saved history and suggest an inline completion. In my PowerShell profile I enable\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\/2022\/03\/get-predictionview.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8777","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=8777"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8777\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=8777"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=8777"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=8777"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}