{"id":4581,"date":"2015-10-30T11:22:43","date_gmt":"2015-10-30T15:22:43","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=4581"},"modified":"2015-10-30T11:26:07","modified_gmt":"2015-10-30T15:26:07","slug":"powershell-friday-fun-capture-the-command","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4581\/powershell-friday-fun-capture-the-command\/","title":{"rendered":"PowerShell Friday Fun: Capture the Command"},"content":{"rendered":"<p>This week's Friday Fun actually has a purpose, at least for me. But I always hope you'll pick up a tip or two that you can use in your own PowerShell work.<\/p>\n<p>Because I write a lot about PowerShell, I am constantly copying pasting between my PowerShell session and usually Microsoft Word. Although the same is true when I am writing help examples for my functions. I can save command output to the clipboard with this trick:<\/p>\n<pre class=\"lang:ps mark:0 decode:true \">\r\nGet-service | Group Status | clip\r\n<\/pre>\n<p>But I never know if the command was successful until I paste and then I need to copy the command again. Over the years I've come up with a number of tools to make this process easier but now I think I finally have it.<\/p>\n<p>My new command is called Out-Copy. It is designed to accept any PowerShell command. The function will essentially pass the results back to the pipeline, so it is like <a title=\"Read online help for Tee-Object\" href=\"http:\/\/go.microsoft.com\/fwlink\/p\/?linkid=294019\" target=\"_blank\">Tee-Object<\/a> in that respect. It also sends a copy of the output to the clipboard. But wait there's more! The clipboard output will include the prompt and the command you ran.<\/p>\n<p>At a PowerShell prompt I can run something like this:<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/10\/103015_1522_PowerShellF1.png\" alt='Using Out-Copy' \/><span style=\"color: #44546a; font-size: 9pt;\"><em>Using Out-Copy (Image Credit: Jeff Hicks)<\/em><\/span><\/p>\n<p>And I can then paste into another application<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/10\/103015_1522_PowerShellF2.png\" alt='Pasted results' \/><span style=\"color: #44546a; font-size: 9pt;\"><em>Pasted results (Image Credit: Jeff Hicks)<\/em><\/span><\/p>\n<p>I also included a parameter to only copy the command to the clipboard. This command runs as expected:<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/10\/103015_1522_PowerShellF3.png\" alt='Copying command only' \/><span style=\"color: #44546a; font-size: 9pt;\"><em>Copying command only (Image Credit: Jeff Hicks)<\/em><\/span><\/p>\n<p>With this result:<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/10\/103015_1522_PowerShellF4.png\" alt='Command only result' \/><span style=\"color: #44546a; font-size: 9pt;\"><em>Command only result (Image Credit: Jeff Hicks)<\/em><\/span><\/p>\n<p>This version of my function will only copy what is sent to the success pipeline. It will not capture anything from the other streams such as Verbose, Warning or Error. Normally I do screen shots of that anyway. But this might be something I'll look into later.<\/p>\n<p>Here's the complete function which includes an alias.<\/p>\n<pre class=\"lang:ps mark:0 decode:true \">\r\n#requires -version 4.0\r\n\r\nFunction Out-Copy {\r\n\r\n&lt;#\r\n.Synopsis\r\nSend command output to the pipeline and Windows clipboard.\r\n.Description\r\nThis command is intended for writers and those who need to document with PowerShell. You can pipe any command to this function and you will get the regular output in your PowerShell session. But a copy of the output will be copied to the Windows clipboard. Additionally, the copy will include your prompt and the command that you executed, without the Out-Copy portion.\r\n\r\nNOTE: You can only capture what is written to the Success pipeline. This command will not copy any other streams such as Verbose or Error.\r\n.Parameter CommandOnly\r\nOnly copy the executed command, without references to Out-Copy, to the Windows clipboard.\r\n.Parameter Width\r\nSpecifies the number of characters in each line of output. Any additional characters are truncated, not wrapped.\r\n.Example\r\nPS C:\\&gt; Get-Process | Sort WS -Descending | Select -first 5 | out-copy\r\n\r\nThis will execute your expression and write the output to the pipeline. In addition this text will be copied to the Windows clipboard:\r\n\r\nPS C:\\&gt; Get-Process | Sort WS -Descending | Select -first 5\r\n\r\nHandles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName\r\n------- ------ ----- ----- ----- ------ -- -----------\r\n1242 133 1047776 1002596 1987 4,499.78 1416 waterfox\r\n1182 101 438800 409020 1285 854.53 6528 powershell_ise\r\n321 22 245568 202236 362 730.05 2484 ZeroConfigService\r\n1314 177 229772 187324 792 ...70.95 6500 SugarSync\r\n651 37 199160 162216 343 597.16 1052 svchost\r\n\r\n.Example\r\nPS C:\\scripts&gt; dir *.ps1 | out-file c:\\work\\ps.txt\r\n\r\nEven if your command doesn't write anything to the pipeline, Out-Copy will still capture your prompt and PowerShell expression.\r\n.Example\r\nPS C:\\&gt; gcim win32_logicaldisk -filter \"drivetype = 3\" | out-copy -commandonly\r\n\r\nThis will run the Get-CimInstance command and write results to the pipeline. But the only text that will be copied to the clipboard is:\r\n\r\ngcim win32_logicaldisk -filter \"drivetype = 3\"\r\n\r\n.Notes\r\nLast Updated: 30 October 2015\r\nVersion : 1.0\r\n\r\nLearn more about PowerShell:\r\n<blockquote class=\"wp-embedded-content\" data-secret=\"R7DW4jlXMr\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/essential-powershell-resources\/\">Essential PowerShell Learning Resources<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;Essential PowerShell Learning Resources&#8221; &#8212; The Lonely Administrator\" src=\"https:\/\/jdhitsolutions.com\/blog\/essential-powershell-resources\/embed\/#?secret=ujflKdunkM#?secret=R7DW4jlXMr\" data-secret=\"R7DW4jlXMr\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\r\n\r\n****************************************************************\r\n* DO NOT USE IN A PRODUCTION ENVIRONMENT UNTIL YOU HAVE TESTED *\r\n* THOROUGHLY IN A LAB ENVIRONMENT. USE AT YOUR OWN RISK. IF *\r\n* YOU DO NOT UNDERSTAND WHAT THIS SCRIPT DOES OR HOW IT WORKS, *\r\n* DO NOT USE IT OUTSIDE OF A SECURE, TEST SETTING. *\r\n****************************************************************\r\n.Link\r\nOut-String\r\n.Inputs\r\n[object]\r\n.Outputs\r\n[object]\r\n\r\n#&gt;\r\n\r\n[cmdletbinding()]\r\nParam(\r\n[Parameter(Mandatory,ValueFromPipeline)]\r\n[object]$InputObject,\r\n[ValidateNotNullorEmpty()]\r\n[int]$Width = 80,\r\n[switch]$CommandOnly\r\n)\r\n\r\nBegin {\r\nWrite-Verbose \"Starting: $($MyInvocation.Mycommand)\"\r\nWrite-Verbose \"Adding necessary .NET assembly\"\r\nAdd-Type -AssemblyName system.windows.forms\r\n\r\n#initialize an array to hold all incoming data\r\n$Data = @()\r\n} #begin\r\n\r\nProcess {\r\n#add each input to the array\r\n$data += $InputObject\r\n\r\n} #process\r\n\r\nEnd {\r\nWrite-Verbose \"In the End block\"\r\n\r\n#write data to the pipeline\r\nWrite-Verbose \"Here is the PowerShell output\"\r\n$data\r\n\r\nWrite-Verbose \"Getting the currently running command\"\r\n$Invoked = $MyInvocation.Line\r\n#parse out the Out-Copy command\r\n$cmd = $Invoked.substring(0,$invoked.LastIndexOf(\"|\"))\r\nif ($CommandOnly) {\r\nWrite-Verbose \"Copying command expression\"\r\n$Text = $cmd\r\n}\r\nelse {\r\n#convert data to text\r\nWrite-Verbose \"Getting current prompt\"\r\n$text = \"$((Prompt | Out-String).Trim()) \"\r\n$text += $cmd\r\n#insert a blank line\r\n$text += \"`n\"\r\nWrite-Verbose \"Converting data to text\"\r\n#using a regular expression to try and clean up the output\r\n$text += ($data | Out-String -Width $Width) -replace \"(?&lt;=\\S*)\\s+`r`n$\",\"`r`n\"\r\n}\r\n\r\nWrite-Verbose \"Copy text to the clipboard\"\r\n[System.Windows.Forms.Clipboard]::SetText( $text,[System.Windows.Forms.TextDataFormat]::Text)\r\nWrite-Verbose \"Ending: $($MyInvocation.Mycommand)\"\r\n} #end\r\n\r\n}\r\n\r\n#define an alias\r\nSet-Alias -Name oc -Value Out-Copy\r\n<\/pre>\n<p>The only other parameter is Width. I have given this a default value of 80 which works best when pasting into a Word or text document. You can adjust this, typically up to the width of your PowerShell host. Anything beyond will be truncated.<\/p>\n<p>I spent a few hours polishing this up, but it will save me time and frustration from here on out and maybe you will need to use it to. Plus it puts a smile on my face when I use it because I feel like I'm performing magic.<\/p>\n<p>Enjoy!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This week&#8217;s Friday Fun actually has a purpose, at least for me. But I always hope you&#8217;ll pick up a tip or two that you can use in your own PowerShell work. Because I write a lot about PowerShell, I am constantly copying pasting between my PowerShell session and usually Microsoft Word. Although the same&#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 #PowerShell Friday Fun: Capture the Command","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":[271,4,8],"tags":[500,568,534],"class_list":["post-4581","post","type-post","status-publish","format-standard","hentry","category-friday-fun","category-powershell","category-scripting","tag-clipboard","tag-friday-fun","tag-powershell"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PowerShell Friday Fun: Capture the Command &#8226; The Lonely Administrator<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/4581\/powershell-friday-fun-capture-the-command\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PowerShell Friday Fun: Capture the Command &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"This week&#039;s Friday Fun actually has a purpose, at least for me. But I always hope you&#039;ll pick up a tip or two that you can use in your own PowerShell work. Because I write a lot about PowerShell, I am constantly copying pasting between my PowerShell session and usually Microsoft Word. Although the same...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/4581\/powershell-friday-fun-capture-the-command\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2015-10-30T15:22:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2015-10-30T15:26:07+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/10\/103015_1522_PowerShellF1.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=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4581\\\/powershell-friday-fun-capture-the-command\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4581\\\/powershell-friday-fun-capture-the-command\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"PowerShell Friday Fun: Capture the Command\",\"datePublished\":\"2015-10-30T15:22:43+00:00\",\"dateModified\":\"2015-10-30T15:26:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4581\\\/powershell-friday-fun-capture-the-command\\\/\"},\"wordCount\":407,\"commentCount\":5,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4581\\\/powershell-friday-fun-capture-the-command\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/103015_1522_PowerShellF1.png\",\"keywords\":[\"Clipboard\",\"Friday Fun\",\"PowerShell\"],\"articleSection\":[\"Friday Fun\",\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4581\\\/powershell-friday-fun-capture-the-command\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4581\\\/powershell-friday-fun-capture-the-command\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4581\\\/powershell-friday-fun-capture-the-command\\\/\",\"name\":\"PowerShell Friday Fun: Capture the Command &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4581\\\/powershell-friday-fun-capture-the-command\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4581\\\/powershell-friday-fun-capture-the-command\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/103015_1522_PowerShellF1.png\",\"datePublished\":\"2015-10-30T15:22:43+00:00\",\"dateModified\":\"2015-10-30T15:26:07+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4581\\\/powershell-friday-fun-capture-the-command\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4581\\\/powershell-friday-fun-capture-the-command\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4581\\\/powershell-friday-fun-capture-the-command\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/103015_1522_PowerShellF1.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/103015_1522_PowerShellF1.png\",\"width\":577,\"height\":183},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/4581\\\/powershell-friday-fun-capture-the-command\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Friday Fun\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/friday-fun\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PowerShell Friday Fun: Capture the Command\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PowerShell Friday Fun: Capture the Command &#8226; The Lonely Administrator","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4581\/powershell-friday-fun-capture-the-command\/","og_locale":"en_US","og_type":"article","og_title":"PowerShell Friday Fun: Capture the Command &#8226; The Lonely Administrator","og_description":"This week's Friday Fun actually has a purpose, at least for me. But I always hope you'll pick up a tip or two that you can use in your own PowerShell work. Because I write a lot about PowerShell, I am constantly copying pasting between my PowerShell session and usually Microsoft Word. Although the same...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4581\/powershell-friday-fun-capture-the-command\/","og_site_name":"The Lonely Administrator","article_published_time":"2015-10-30T15:22:43+00:00","article_modified_time":"2015-10-30T15:26:07+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/10\/103015_1522_PowerShellF1.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":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4581\/powershell-friday-fun-capture-the-command\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4581\/powershell-friday-fun-capture-the-command\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"PowerShell Friday Fun: Capture the Command","datePublished":"2015-10-30T15:22:43+00:00","dateModified":"2015-10-30T15:26:07+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4581\/powershell-friday-fun-capture-the-command\/"},"wordCount":407,"commentCount":5,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4581\/powershell-friday-fun-capture-the-command\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/10\/103015_1522_PowerShellF1.png","keywords":["Clipboard","Friday Fun","PowerShell"],"articleSection":["Friday Fun","PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/4581\/powershell-friday-fun-capture-the-command\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4581\/powershell-friday-fun-capture-the-command\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4581\/powershell-friday-fun-capture-the-command\/","name":"PowerShell Friday Fun: Capture the Command &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4581\/powershell-friday-fun-capture-the-command\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4581\/powershell-friday-fun-capture-the-command\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/10\/103015_1522_PowerShellF1.png","datePublished":"2015-10-30T15:22:43+00:00","dateModified":"2015-10-30T15:26:07+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4581\/powershell-friday-fun-capture-the-command\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/4581\/powershell-friday-fun-capture-the-command\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4581\/powershell-friday-fun-capture-the-command\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/10\/103015_1522_PowerShellF1.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2015\/10\/103015_1522_PowerShellF1.png","width":577,"height":183},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4581\/powershell-friday-fun-capture-the-command\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Friday Fun","item":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},{"@type":"ListItem","position":2,"name":"PowerShell Friday Fun: Capture the 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":8777,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8777\/copy-powershell-history-command\/","url_meta":{"origin":4581,"position":0},"title":"Copy PowerShell History Command","author":"Jeffery Hicks","date":"January 11, 2022","format":false,"excerpt":"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 h. To re-rerun a command use\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\/01\/ch.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/ch.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/ch.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/ch.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/ch.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2022\/01\/ch.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":2002,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell-v2-0\/2002\/friday-fun-output-to-2-places-in-1\/","url_meta":{"origin":4581,"position":1},"title":"Friday Fun: Output to 2 Places in 1","author":"Jeffery Hicks","date":"January 13, 2012","format":false,"excerpt":"Today's Friday Fun comes out of a short exchange I had yesterday with Hal Rottenberg on Google Plus. We were playing around with piping a PowerShell command to Clip.exe which dumps the output to the Windows Clipboard. I got to thinking about taking this a step further based on my\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2012\/01\/out-tee-1-300x141.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":693,"url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/693\/out-clip\/","url_meta":{"origin":4581,"position":2},"title":"Out-Clip","author":"Jeffery Hicks","date":"July 6, 2010","format":false,"excerpt":"I\u2019ve started working on the 2nd edition of Managing Active Directory with Windows PowerShell: TFM. As with almost all of my writing projects it will be full of PowerShell code examples. In the past I\u2019ve always relied on a manual copy and paste to add content to the manuscript. The\u2026","rel":"","context":"In &quot;PowerShell v2.0&quot;","block_context":{"text":"PowerShell v2.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-v2-0\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2962,"url":"https:\/\/jdhitsolutions.com\/blog\/friday-fun\/2962\/friday-fun-powershell-commands-by-noun\/","url_meta":{"origin":4581,"position":3},"title":"Friday Fun PowerShell Commands by Noun","author":"Jeffery Hicks","date":"April 19, 2013","format":false,"excerpt":"One of PowerShell's greatest strength's is discoverability. Once you know how, it is very easy to discover what \u00a0you can do with PowerShell and how. One reason this works is because PowerShell commands follow a consistent verb-noun naming convention. With this in mind, you can see all of the commands\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"get-command-noun-01","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/04\/get-command-noun-01-1024x577.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/04\/get-command-noun-01-1024x577.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/04\/get-command-noun-01-1024x577.png?resize=525%2C300 1.5x"},"classes":[]},{"id":4407,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4407\/friday-fun-a-powershell-macro\/","url_meta":{"origin":4581,"position":4},"title":"Friday Fun: A PowerShell Macro","author":"Jeffery Hicks","date":"May 15, 2015","format":false,"excerpt":"Today's Friday Fun is a little different in that it showcases two things I use almost every day: Microsoft Word and PowerShell. I am writing new articles and material almost daily and of course very often the content is PowerShell related. Usually I use the blog post template in Word\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4895,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4895\/friday-fun-a-sysinternals-powershell-workflow\/","url_meta":{"origin":4581,"position":5},"title":"Friday Fun: A SysInternals PowerShell Workflow","author":"Jeffery Hicks","date":"February 12, 2016","format":false,"excerpt":"Over the years I've come up with a number of PowerShell tools to download the SysInternals tools to my desktop. And yes, I know that with PowerShell 5 and PowerShellGet I could download and install a SysInternals package. But that assumes the package is current.\u00a0 But that's not really the\u2026","rel":"","context":"In &quot;Friday Fun&quot;","block_context":{"text":"Friday Fun","link":"https:\/\/jdhitsolutions.com\/blog\/category\/friday-fun\/"},"img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/02\/image_thumb-5.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/02\/image_thumb-5.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/02\/image_thumb-5.png?resize=525%2C300 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4581","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=4581"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4581\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=4581"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=4581"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=4581"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}