Get-Clipboard

Get the current Windows clipboard entry.

Syntax
      Get-Clipboard [-Format ClipboardFormat] [-TextFormatType TextDataFormat] [-Raw]
         [CommonParameters]

Key
   -Format ClipboardFormat
       The type, or format, of the clipboard.
       Acceptable values for this are:   Text, FileDropList, Image, Audio

   -Raw
       Ignore newline characters and get the entire content of the clipboard.

   -TextFormatType TextDataFormat
       The text data format type of the clipboard.
       Acceptable values for this are:   Text, UnicodeText, Rtf, Html, CommaSeparatedValue

Standard Aliases for Get-Clipboard: none, but if you want to add a short alias like clip, set it with set-alias

Examples

Get the content of the clipboard and display it on the command-line:

PS C:\> Get-Clipboard
This is a test string

Get multiple lines of text from the clipboard, auto-wrap the text to 40 chars wide and then copy back to the clipboard (via Lee Holmes):

PS C:\> (Get-Clipboard -Raw) -replace '(?s)\S\r\n(\S)',' $1' -replace '(.{1,40})(\s|$)',"`$1`r`n" | Set-Clipboard

“O nation, that thou couldst remove! That Neptune's arms, who clippeth thee about, Would bear thee from the knowledge of thyself” ~ King John (Act 5 Scene 2) - Shakespeare

Related PowerShell Cmdlets

Set-Clipboard - Set the current Windows clipboard entry.
Equivalent CMD command: CLIP


 
Copyright © 1999-2024 SS64.com
Some rights reserved