{"id":693,"date":"2010-07-06T13:07:19","date_gmt":"2010-07-06T18:07:19","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/2010\/07\/out-clip\/"},"modified":"2010-07-06T13:30:59","modified_gmt":"2010-07-06T18:30:59","slug":"out-clip","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/scripting\/693\/out-clip\/","title":{"rendered":"Out-Clip"},"content":{"rendered":"<p>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 <a href=\"http:\/\/codeplex.com\/pscx\" target=\"_blank\">PowerShell Community Extensions<\/a> made this a little easier in the past with their <strong>Out-Clipboard<\/strong> cmdlet. That made it easier to grab the results so I could paste them in my Word document. But I also needed the PowerShell command which meant another copy and paste. What I really needed was a way to grab the expression AND the result and send both to the Windows clipboard. Thus was born Out-Clip.<\/p>\n<div id=\"codeSnippetWrapper\" style=\"border: 1px solid silver; text-align: left; padding: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: 'Courier New',courier,monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text;\">\n<div id=\"codeSnippet\" style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\">\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum1\" style=\"color: #606060;\">   1:<\/span> Function Out-Clip {<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum2\" style=\"color: #606060;\">   2:<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum3\" style=\"color: #606060;\">   3:<\/span> &lt;<span style=\"color: #008000;\">#<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum4\" style=\"color: #606060;\">   4:<\/span> .Synopsis<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum5\" style=\"color: #606060;\">   5:<\/span> Capture a PowerShell command and its result to the Windows clipboard.<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum6\" style=\"color: #606060;\">   6:<\/span> .Description<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum7\" style=\"color: #606060;\">   7:<\/span> Using Write-Clipboard from the PowerShell Community Extensions,<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum8\" style=\"color: #606060;\">   8:<\/span> this <span style=\"color: #0000ff;\">function<\/span> will take a Windows PowerShell scriptblock, execute<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum9\" style=\"color: #606060;\">   9:<\/span> it and write both the command and the results to the Windows clipboard.<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum10\" style=\"color: #606060;\">  10:<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum11\" style=\"color: #606060;\">  11:<\/span> You can also pipe a collection of scriptblocks to this <span style=\"color: #0000ff;\">function<\/span> or use<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum12\" style=\"color: #606060;\">  12:<\/span> a comma separated list with the -Scriptblock parameter.<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum13\" style=\"color: #606060;\">  13:<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum14\" style=\"color: #606060;\">  14:<\/span> By <span style=\"color: #0000ff;\">default<\/span> the output will include the PS prompt set to PS C:\\&gt;.<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum15\" style=\"color: #606060;\">  15:<\/span> If you want to use the actual current location then specify<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum16\" style=\"color: #606060;\">  16:<\/span> -UseCurrentLocation. If you prefer no prompt at all then use -NoLocation.<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum17\" style=\"color: #606060;\">  17:<\/span> .Parameter ScriptBlock<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum18\" style=\"color: #606060;\">  18:<\/span> The scriptblock command you wish to execute.<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum19\" style=\"color: #606060;\">  19:<\/span> .Parameter UseCurrentLocation<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum20\" style=\"color: #606060;\">  20:<\/span> Use the current location <span style=\"color: #0000ff;\">for<\/span> the prompt instead of PS C:\\&gt;<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum21\" style=\"color: #606060;\">  21:<\/span> .Parameter NoLocation<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum22\" style=\"color: #606060;\">  22:<\/span> Do not include any prompt information. Only display the<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum23\" style=\"color: #606060;\">  23:<\/span> <span style=\"color: #0000ff;\">script<\/span> block and results.<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum24\" style=\"color: #606060;\">  24:<\/span> .Example<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum25\" style=\"color: #606060;\">  25:<\/span> PS C:\\&gt; Out-Clip {get-<span style=\"color: #0000ff;\">process<\/span> | where {$_.ws <span style=\"color: #cc6633;\">-gt<\/span> 50MB}}<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum26\" style=\"color: #606060;\">  26:<\/span> .Example<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum27\" style=\"color: #606060;\">  27:<\/span> PS C:\\Users\\Jeff\\Documents\\&gt; Out-Clip {dir -recurse -<span style=\"color: #0000ff;\">filter<\/span> *.doc} -UseCurrentLocation<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum28\" style=\"color: #606060;\">  28:<\/span> .Example<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum29\" style=\"color: #606060;\">  29:<\/span> PS C:\\Work\\&gt; {get-<span style=\"color: #0000ff;\">process<\/span>},{get-service} | Out-Clip  -nolocation<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum30\" style=\"color: #606060;\">  30:<\/span> .Inputs<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum31\" style=\"color: #606060;\">  31:<\/span> A scriptblock<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum32\" style=\"color: #606060;\">  32:<\/span> .Outputs<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum33\" style=\"color: #606060;\">  33:<\/span> None<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum34\" style=\"color: #606060;\">  34:<\/span> .Link<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum35\" style=\"color: #606060;\">  35:<\/span> Write-Clipboard<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum36\" style=\"color: #606060;\">  36:<\/span> Set-Clipboard<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum37\" style=\"color: #606060;\">  37:<\/span> Out-Clipboard<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum38\" style=\"color: #606060;\">  38:<\/span> Get-Clipboard<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum39\" style=\"color: #606060;\">  39:<\/span> .Notes<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum40\" style=\"color: #606060;\">  40:<\/span> Version    : 1.0<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum41\" style=\"color: #606060;\">  41:<\/span> Name       : Out-Clip<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum42\" style=\"color: #606060;\">  42:<\/span> Last Update: 7\/6\/2010<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum43\" style=\"color: #606060;\">  43:<\/span> URL        : http:\/\/jdhitsolutions.com\/blog<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum44\" style=\"color: #606060;\">  44:<\/span> <span style=\"color: #008000;\">#&gt;<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum45\" style=\"color: #606060;\">  45:<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum46\" style=\"color: #606060;\">  46:<\/span> [cmdletBinding(DefaultParameterSetName=<span style=\"color: #006080;\">\"Location\"<\/span>)]<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum47\" style=\"color: #606060;\">  47:<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum48\" style=\"color: #606060;\">  48:<\/span> Param(<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum49\" style=\"color: #606060;\">  49:<\/span>     [Parameter(Position=0,Mandatory=$True,ValueFromPipeline=$True,<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum50\" style=\"color: #606060;\">  50:<\/span>     HelpMessage=<span style=\"color: #006080;\">\"Enter a PowerShell expression\"<\/span>)]<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum51\" style=\"color: #606060;\">  51:<\/span>     [ValidateNotNullorEmpty()]<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum52\" style=\"color: #606060;\">  52:<\/span>     [scriptblock[]]$ScriptBlock,<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum53\" style=\"color: #606060;\">  53:<\/span>     [Parameter(ParameterSetName=<span style=\"color: #006080;\">\"Location\"<\/span>)]<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum54\" style=\"color: #606060;\">  54:<\/span>     [<span style=\"color: #0000ff;\">switch<\/span>]$UseCurrentLocation,<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum55\" style=\"color: #606060;\">  55:<\/span>     [Parameter(ParameterSetName=<span style=\"color: #006080;\">\"NoLocation\"<\/span>)]<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum56\" style=\"color: #606060;\">  56:<\/span>     [<span style=\"color: #0000ff;\">switch<\/span>]$NoLocation<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum57\" style=\"color: #606060;\">  57:<\/span>     )<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum58\" style=\"color: #606060;\">  58:<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum59\" style=\"color: #606060;\">  59:<\/span> Begin {<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum60\" style=\"color: #606060;\">  60:<\/span>      Write-Verbose <span style=\"color: #006080;\">\"Starting $($myinvocation.mycommand)\"<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum61\" style=\"color: #606060;\">  61:<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum62\" style=\"color: #606060;\">  62:<\/span>      Try {<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum63\" style=\"color: #606060;\">  63:<\/span>         Write-Verbose <span style=\"color: #006080;\">\"Verifying Write-Clipboard\"<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum64\" style=\"color: #606060;\">  64:<\/span>         Get-Command -Name <span style=\"color: #006080;\">\"Write-Clipboard\"<\/span> -ErrorAction <span style=\"color: #006080;\">\"Stop\"<\/span> | Out-Null<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum65\" style=\"color: #606060;\">  65:<\/span>      }<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum66\" style=\"color: #606060;\">  66:<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum67\" style=\"color: #606060;\">  67:<\/span>     Catch {<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum68\" style=\"color: #606060;\">  68:<\/span>         Write-Warning <span style=\"color: #006080;\">\"Failed to find Write-Clipboard from the PowerShell Community Extensions.\"<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum69\" style=\"color: #606060;\">  69:<\/span>         Break<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum70\" style=\"color: #606060;\">  70:<\/span>     }<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum71\" style=\"color: #606060;\">  71:<\/span>     <span style=\"color: #008000;\">#define prompt to display, if any<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum72\" style=\"color: #606060;\">  72:<\/span>     <span style=\"color: #0000ff;\">if<\/span> ($NoLocation) {<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum73\" style=\"color: #606060;\">  73:<\/span>         Write-Verbose <span style=\"color: #006080;\">\"NoPrompt specified\"<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum74\" style=\"color: #606060;\">  74:<\/span>         $myPrompt=<span style=\"color: #006080;\">\"\"<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum75\" style=\"color: #606060;\">  75:<\/span>     }<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum76\" style=\"color: #606060;\">  76:<\/span>     <span style=\"color: #0000ff;\">elseif<\/span> ($UseCurrentLocation) {<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum77\" style=\"color: #606060;\">  77:<\/span>         Write-Verbose <span style=\"color: #006080;\">\"Using current location $($pwd)\"<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum78\" style=\"color: #606060;\">  78:<\/span>         $myPrompt=<span style=\"color: #006080;\">\"PS $pwd\\&gt; \"<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum79\" style=\"color: #606060;\">  79:<\/span>     }<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum80\" style=\"color: #606060;\">  80:<\/span>     <span style=\"color: #0000ff;\">else<\/span> {<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum81\" style=\"color: #606060;\">  81:<\/span>         Write-Verbose <span style=\"color: #006080;\">\"Using default prompt\"<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum82\" style=\"color: #606060;\">  82:<\/span>         $myPrompt=<span style=\"color: #006080;\">\"PS C:\\&gt; \"<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum83\" style=\"color: #606060;\">  83:<\/span>     }<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum84\" style=\"color: #606060;\">  84:<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum85\" style=\"color: #606060;\">  85:<\/span>     <span style=\"color: #008000;\">#initialize an array to hold results<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum86\" style=\"color: #606060;\">  86:<\/span>     Write-Verbose <span style=\"color: #006080;\">\"Initializing output array\"<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum87\" style=\"color: #606060;\">  87:<\/span>     $output=@{}<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum88\" style=\"color: #606060;\">  88:<\/span> } <span style=\"color: #008000;\">#close Begin<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum89\" style=\"color: #606060;\">  89:<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum90\" style=\"color: #606060;\">  90:<\/span> Process {<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum91\" style=\"color: #606060;\">  91:<\/span>     <span style=\"color: #0000ff;\">foreach<\/span> ($sb <span style=\"color: #0000ff;\">in<\/span> $scriptblock) {<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum92\" style=\"color: #606060;\">  92:<\/span>         <span style=\"color: #008000;\">#run the command and save the result<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum93\" style=\"color: #606060;\">  93:<\/span>         Write-Verbose <span style=\"color: #006080;\">\"Executing scriptblock\"<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum94\" style=\"color: #606060;\">  94:<\/span>         Write-Verbose $sb.ToString()<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum95\" style=\"color: #606060;\">  95:<\/span>         $result=&amp;$sb<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum96\" style=\"color: #606060;\">  96:<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum97\" style=\"color: #606060;\">  97:<\/span>         <span style=\"color: #008000;\">#check if the command succeeded. If not, then get the<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum98\" style=\"color: #606060;\">  98:<\/span>         <span style=\"color: #008000;\">#last exception and make it the result<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum99\" style=\"color: #606060;\">  99:<\/span>         <span style=\"color: #0000ff;\">if<\/span> (-not $result) {<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum100\" style=\"color: #606060;\"> 100:<\/span>             Write-Verbose <span style=\"color: #006080;\">\"Adding exception\"<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum101\" style=\"color: #606060;\"> 101:<\/span>             $result=$error[0]<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum102\" style=\"color: #606060;\"> 102:<\/span>         }<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum103\" style=\"color: #606060;\"> 103:<\/span>         Write-Verbose <span style=\"color: #006080;\">\"Building data and adding to hash table\"<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum104\" style=\"color: #606060;\"> 104:<\/span>         <span style=\"color: #008000;\">#define the first line with the prompt and command<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum105\" style=\"color: #606060;\"> 105:<\/span>         $commandline=<span style=\"color: #006080;\">\"{0}{1}\"<\/span> -f $myPrompt,$sb.ToString()<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum106\" style=\"color: #606060;\"> 106:<\/span>         <span style=\"color: #008000;\">#add the command and results to the hash table<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum107\" style=\"color: #606060;\"> 107:<\/span>         $output.Add($commandline,($result | out-string))<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum108\" style=\"color: #606060;\"> 108:<\/span>     } <span style=\"color: #008000;\">#foreach $sb in $scriptblockl<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum109\" style=\"color: #606060;\"> 109:<\/span> } <span style=\"color: #008000;\">#close Process<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum110\" style=\"color: #606060;\"> 110:<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum111\" style=\"color: #606060;\"> 111:<\/span> End {<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum112\" style=\"color: #606060;\"> 112:<\/span>     Write-Verbose <span style=\"color: #006080;\">\"Writing output to the clipboard\"<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum113\" style=\"color: #606060;\"> 113:<\/span>     <span style=\"color: #008000;\">#enumerate the keys and then the command results<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum114\" style=\"color: #606060;\"> 114:<\/span>     $output.keys | <span style=\"color: #0000ff;\">foreach<\/span> {$_,($output.item($_) | out-string)} | write-clipboard<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum115\" style=\"color: #606060;\"> 115:<\/span>     Write-Verbose <span style=\"color: #006080;\">\"Command and results written to the clipboard.\"<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum116\" style=\"color: #606060;\"> 116:<\/span>     Write-Verbose <span style=\"color: #006080;\">\"Ending $($myinvocation.mycommand)\"<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum117\" style=\"color: #606060;\"> 117:<\/span> } <span style=\"color: #008000;\">#close end<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum118\" style=\"color: #606060;\"> 118:<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum119\" style=\"color: #606060;\"> 119:<\/span> } #<span style=\"color: #0000ff;\">end<\/span> function<\/pre>\n<p><!--CRLF--><\/p>\n<\/div>\n<\/div>\n<p>The function requires the <strong>Write-Clipboard<\/strong> cmdlet from the PowerShell Community Extensions. I use a Try\/Catch block to verify the cmdlet exists in your current session. If it doesn\u2019t, you get an error message and the pipeline is terminated. You\u2019ll need to make sure you manually load the module before running this function.<\/p>\n<p>The function itself is pretty basic I think. You can specify one or more scriptblocks either with the \u2013Scriptblock parameter or piped into the function.<\/p>\n<p><span style=\"font-family: Courier New; color: #0000ff; font-size: small;\">PS C:\\&gt; out-clip {get-service spooler | select *}<\/span><\/p>\n<p>Since I prefer almost all of my code examples to use a prompt of PS C:\\&gt;, the function prepends it before the scriptblock command. If you prefer to see the actual or current location, use the \u2013UseCurrentLocation parameter. If you prefer no prompt, then use \u2013NoLocation. Because these two values are mutually exclusive, I\u2019ve used two parameter sets, which you can see when you look at help.<\/p>\n<p><span style=\"font-family: Courier New; color: #0000ff; font-size: small;\">PS C:\\&gt; get-help out-clip <\/span><\/p>\n<p><span style=\"font-family: Courier New; color: #0000ff; font-size: small;\">NAME<\/span><\/p>\n<p><span style=\"font-family: Courier New; color: #0000ff; font-size: small;\">Out-Clip<\/span><\/p>\n<p><span style=\"font-family: Courier New; color: #0000ff; font-size: small;\">SYNOPSIS <\/span><\/p>\n<p><span style=\"font-family: Courier New; color: #0000ff; font-size: small;\"> Capture a PowerShell command and its result to the Windows clipboard. <\/span><\/p>\n<p><span style=\"font-family: Courier New; color: #0000ff; font-size: small;\">SYNTAX <\/span><\/p>\n<p><span style=\"font-family: Courier New; color: #0000ff; font-size: small;\"> Out-Clip [-ScriptBlock] &lt;ScriptBlock[]&gt; [-UseCurrentLocation] [&lt;CommonParameters&gt;] <\/span><\/p>\n<p><span style=\"font-family: Courier New; color: #0000ff; font-size: small;\"> Out-Clip [-ScriptBlock] &lt;ScriptBlock[]&gt; [-NoLocation] [&lt;CommonParameters&gt;] <\/span><\/p>\n<p><span style=\"font-family: Courier New; color: #0000ff; font-size: small;\">DESCRIPTION <\/span><\/p>\n<p><span style=\"font-family: Courier New; color: #0000ff; font-size: small;\"> Using Write-Clipboard from the PowerShell Community Extensions, <\/span><\/p>\n<p><span style=\"font-family: Courier New; color: #0000ff; font-size: small;\"> <\/span><span style=\"font-family: Courier New; color: #0000ff; font-size: small;\"> this function will take a Windows PowerShell scriptblock, execute<\/span><\/p>\n<p>it and write both the command and the results to the Windows clipboard.<\/p>\n<p><span style=\"font-family: Courier New; color: #0000ff; font-size: small;\"> You can also pipe a collection of scriptblocks to this function or use <\/span><\/p>\n<p><span style=\"font-family: Courier New; color: #0000ff; font-size: small;\"> a comma separated list with the -Scriptblock parameter. <\/span><\/p>\n<p><span style=\"font-family: Courier New; color: #0000ff; font-size: small;\"> By default the output will include the PS prompt set to PS C:\\&gt;. <\/span><\/p>\n<p><span style=\"font-family: Courier New; color: #0000ff; font-size: small;\"> If you want to use the actual current location then specify <\/span><\/p>\n<p><span style=\"font-family: Courier New; color: #0000ff; font-size: small;\"> -UseCurrentLocation. If you prefer no prompt at all then use -NoLocation.<\/span><\/p>\n<p><span style=\"font-family: Courier New; color: #0000ff; font-size: small;\">RELATED LINKS<\/span><\/p>\n<p><span style=\"font-family: Courier New; color: #0000ff; font-size: x-small;\">Write-Clipboard<\/span><\/p>\n<p><span style=\"font-family: Courier New; color: #0000ff; font-size: small;\"> Set-Clipboard <\/span><\/p>\n<p><span style=\"font-family: Courier New; color: #0000ff; font-size: small;\"> Out-Clipboard <\/span><\/p>\n<p><span style=\"font-family: Courier New; color: #0000ff; font-size: small;\"> Get-Clipboard <\/span><\/p>\n<p><span style=\"font-family: Courier New; color: #0000ff; font-size: small;\">REMARKS<\/span><\/p>\n<p><span style=\"font-family: Courier New; color: #0000ff; font-size: small;\">To see the examples, type: \"get-help Out-Clip -examples\".<\/span><\/p>\n<p><span style=\"font-family: Courier New; color: #0000ff; font-size: small;\"> For more information, type: \"get-help Out-Clip -detailed\". <\/span><\/p>\n<p><span style=\"font-family: Courier New; color: #0000ff; font-size: small;\"> For technical information, type: \"get-help Out-Clip -full\". <\/span><\/p>\n<p>Out-Clip uses a hash-table to store the scriptblock command and the result. If the scriptblock fails, then the last error is grabbed and used instead for the result. Thus I always get the command and result in the clipboard, even if the command failed. After all scriptblocks have been evaluated the hash-table\u2019s contents are piped to <strong>Write-Clipboard<\/strong>.<\/p>\n<div id=\"codeSnippetWrapper\" style=\"border: 1px solid silver; text-align: left; padding: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: 'Courier New',courier,monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text;\">\n<div id=\"codeSnippet\" style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\">\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum1\" style=\"color: #606060;\">   1:<\/span> End {<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum2\" style=\"color: #606060;\">   2:<\/span>     Write-Verbose <span style=\"color: #006080;\">\"Writing output to the clipboard\"<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum3\" style=\"color: #606060;\">   3:<\/span>     <span style=\"color: #008000;\">#enumerate the keys and then the command results<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum4\" style=\"color: #606060;\">   4:<\/span>     $output.keys | <span style=\"color: #0000ff;\">foreach<\/span> {$_,($output.item($_) | out-string)} | write-clipboard<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum5\" style=\"color: #606060;\">   5:<\/span>     Write-Verbose <span style=\"color: #006080;\">\"Command and results written to the clipboard.\"<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum6\" style=\"color: #606060;\">   6:<\/span>     Write-Verbose <span style=\"color: #006080;\">\"Ending $($myinvocation.mycommand)\"<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum7\" style=\"color: #606060;\">   7:<\/span> } #close end<\/pre>\n<p><!--CRLF--><\/p>\n<\/div>\n<\/div>\n<p>The script file also defines an alias, <em>oc<\/em>, for the function since I don\u2019t like to type anymore than I have to.<\/p>\n<p>Granted, this function meets a pretty specific need, but it does demonstrate some PowerShell 2.0 scripting features such as multiple parameter sets, Try\/Catch and hash tables. If you try it out, I hope you\u2019ll let me know what you think.<\/p>\n<div id=\"scid:F60BB8FA-6F02-4999-8F5E-9DD4E92C4DA7:9cad1009-4b3a-4e26-bc17-939f2d7fe1ff\" class=\"wlWriterEditableSmartContent\" style=\"margin: 0px; display: inline; float: none; padding: 0px;\">\n<div><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2010\/07\/OutClip.txt\" target=\"_blank\">Download Out-Clip.ps1<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>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 PowerShell Community Extensions made this&#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":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[75,79,8],"tags":[145,32,199,534,198,82,540],"class_list":["post-693","post","type-post","status-publish","format-standard","hentry","category-powershell-v2-0","category-sapien-press","category-scripting","tag-array","tag-functions","tag-hashtable","tag-powershell","tag-pscx","tag-scriptblock","tag-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Out-Clip &#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\/693\/out-clip\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Out-Clip &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"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 PowerShell Community Extensions made this...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/scripting\/693\/out-clip\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2010-07-06T18:07:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2010-07-06T18:30:59+00:00\" \/>\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\\\/scripting\\\/693\\\/out-clip\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/693\\\/out-clip\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Out-Clip\",\"datePublished\":\"2010-07-06T18:07:19+00:00\",\"dateModified\":\"2010-07-06T18:30:59+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/693\\\/out-clip\\\/\"},\"wordCount\":558,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"keywords\":[\"Array\",\"functions\",\"hashtable\",\"PowerShell\",\"PSCX\",\"ScriptBlock\",\"Scripting\"],\"articleSection\":[\"PowerShell v2.0\",\"SAPIEN Press\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/693\\\/out-clip\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/693\\\/out-clip\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/693\\\/out-clip\\\/\",\"name\":\"Out-Clip &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"datePublished\":\"2010-07-06T18:07:19+00:00\",\"dateModified\":\"2010-07-06T18:30:59+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/693\\\/out-clip\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/693\\\/out-clip\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/scripting\\\/693\\\/out-clip\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell v2.0\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell-v2-0\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Out-Clip\"}]},{\"@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":"Out-Clip &#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\/693\/out-clip\/","og_locale":"en_US","og_type":"article","og_title":"Out-Clip &#8226; The Lonely Administrator","og_description":"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 PowerShell Community Extensions made this...","og_url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/693\/out-clip\/","og_site_name":"The Lonely Administrator","article_published_time":"2010-07-06T18:07:19+00:00","article_modified_time":"2010-07-06T18:30:59+00:00","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\/scripting\/693\/out-clip\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/693\/out-clip\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Out-Clip","datePublished":"2010-07-06T18:07:19+00:00","dateModified":"2010-07-06T18:30:59+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/693\/out-clip\/"},"wordCount":558,"commentCount":1,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"keywords":["Array","functions","hashtable","PowerShell","PSCX","ScriptBlock","Scripting"],"articleSection":["PowerShell v2.0","SAPIEN Press","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/693\/out-clip\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/693\/out-clip\/","url":"https:\/\/jdhitsolutions.com\/blog\/scripting\/693\/out-clip\/","name":"Out-Clip &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"datePublished":"2010-07-06T18:07:19+00:00","dateModified":"2010-07-06T18:30:59+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/693\/out-clip\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/scripting\/693\/out-clip\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/scripting\/693\/out-clip\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell v2.0","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-v2-0\/"},{"@type":"ListItem","position":2,"name":"Out-Clip"}]},{"@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":693,"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":4581,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4581\/powershell-friday-fun-capture-the-command\/","url_meta":{"origin":693,"position":1},"title":"PowerShell Friday Fun: Capture the Command","author":"Jeffery Hicks","date":"October 30, 2015","format":false,"excerpt":"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\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":4293,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4293\/send-from-powershell-ise-to-microsoft-word-revisited\/","url_meta":{"origin":693,"position":2},"title":"Send from PowerShell ISE to Microsoft Word Revisited","author":"Jeffery Hicks","date":"March 16, 2015","format":false,"excerpt":"Many of you seemed to like my little PowerShell ISE add-on to send text from the script pane to a Word document. I should have known someone would ask about a way to make it colorized. You can manually select lines in a script and when you paste them 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":2002,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell-v2-0\/2002\/friday-fun-output-to-2-places-in-1\/","url_meta":{"origin":693,"position":3},"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":917,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/917\/understanding-powershell-background-jobs\/","url_meta":{"origin":693,"position":4},"title":"Understanding PowerShell Background Jobs","author":"Jeffery Hicks","date":"September 9, 2010","format":false,"excerpt":"Last night I spoke to the CNY .NET Developers Group about background jobs in Windows PowerShell. Even though the audience was primarily developers, I discussed jobs from an administrator's perspective, that is, using cmdlets. The job feature in PowerShell 2.0 is pretty amazing and you don't need any programming skills.\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":5907,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5907\/extending-vscode-with-powershell\/","url_meta":{"origin":693,"position":5},"title":"Extending VSCode with PowerShell","author":"Jeffery Hicks","date":"March 2, 2018","format":false,"excerpt":"Last year I made a conscious decision to jump into VS Code as my primary PowerShell development tool. I had spent years tweaking and customizing the PowerShell ISE so I was a little concerned about the transition.\u00a0 But I knew the only way I'd master VS Code (and I still\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\/2018\/03\/image_thumb-3.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/03\/image_thumb-3.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/03\/image_thumb-3.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/03\/image_thumb-3.png?resize=700%2C400&ssl=1 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/693","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=693"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/693\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=693"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=693"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=693"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}