PowerShell

Use clipboard in PowerShell

0
(0)

How to use PowerShell Clipboard

Powershell

PowerShell provide a cmdlet for use the clipboard, advanced applications are allowed, from PowerShell save multible items to the clipboard to use later, it is possible to append content to already pasted items in the clipboard.

The PowerShell Command Set-Clipboard copies a text to the clipboard.

Set-Clipboard "but this to clipboard.."

The text you just copied can be retrieved with get-clipboard.

Get-Clipboard

With -Append copy a text to the existing one.

Write-Output "append something to" | Set-Clipboard -Append
Get-Clipboard

This the query again with Get-Clipboard.

The following command deletes the contents on the clipboard.

Write-Host "delete items in clipboard.." $null | clip

And there is even more to go, if you want to retrieve files and folders that are to be copied from the clipboard, the following command gives the output.

Get-Clipboard -Format FileDropList
Get-Clipboard -Format FileDropList

It is also useful to copy the text content of files directly without opening the file to clipboard, such as scripts or source code.

Get-Content copies the content of test.bat to the clipboard.

Get-Content test.bat | clip

Compare-Object compares the content and copies it to the clipboard.

Compare-Object $(Get-Content c:\temp\test.bat) $(Get-Content c:\temp\test1.bat) | clip

The default of Compare-Object is not case sensitive, use the parameter -CaseSensitive to distinguish small and capital letters.

Help with examples for use can be found with Get-Help.

Get-Help Set Clipboard -Detailed
Get-Help Get Clipboard -Detailed

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Leave a Reply

Your email address will not be published.