Monday, January 9, 2012

Sending Text to Clipboard Everywhere using Powershell

In a previous tip you learned how to use clip.exe to send results to the clipboard. But what if you don't have clip.exe (let's say on Windows XP) or don't want dependencies?

Here's a clever alternative:

function Out-Clipboard {




 Add-Type -AssemblyName System.Windows.Forms

 $tb = New-Object System.Windows.Forms.TextBox

 $tb.Multiline = $true


 if ($Input -ne $null) {


  $tb.Text = $Input | Out-String

 } else {

  $tb.Text = $text





Use it like this:

PS> Get-Process | Out-Clipboard

It solely uses .NET Framework functionality that is available in all versions and modes of PowerShell

1 comment:

  1. It's clear that advices from might be really helpful if you need to get homework motivation.