PSTip: Save untitled tabs in PowerShell ISE to clipboard

When working with the PowerShell ISE it can occur that there are a lot of untitled scripts left at the end of a busy day of scripting. Occasionally something interesting or useful could be left in those tabs. The following function can be used to copy the content from the untitled tabs to the clipboard.

The function uses the $_.IsUntitled property of each open file in the ISE to detect if the tab is untitled. The contents of all tabs are piped into clip.exe:

Function Send-UntitledToClip {
    $psISE.PowerShellTabs.Files | Where-Object {$_.IsUntitled} | ForEach-Object {
        $_.Editor.Text
    } | clip.exe
} 

About the author: Jaap Brasser

Jaap is a Senior System Engineer in the Financial Services industry. He focuses on Microsoft and related technologies and has a passion for PowerShell. In his spare time he maintains his Blog, Twitter feed, @Jaap_Brasser, and contributes on the Official Scripting Guys Forum and Windows PowerShell TechNet forums

Related Posts

%d bloggers like this: