Monday, January 9, 2012

Reading the Clipboard using Powershell

 

PowerTip of the Day, from PowerShell.com:

 

What if you wanted to paste information from the clipboard? No sweat, here is a Get-Clipboard function that outputs any text held by the clipboard:

function Get-Clipboard {

 Add-Type -AssemblyName System.Windows.Forms

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

 $tb.Multiline = $true

 $tb.Paste()

 $tb.Text

}

In a previous tip we presented the corresponding Out-Clipboard function, so now you could send information to the clipboard in one PowerShell session and read it back from another.

Thanks

Aman

1 comment:

  1. I have to say that you guys are doing excellent work. This post describes reading clipboard using powershell. The code given for performing this task is easy and simple. The logic behind the code is simple to understand.
    digital signatures

    ReplyDelete

Note: Only a member of this blog may post a comment.