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 {
    } | clip.exe
Share on: