Get Clipboard - PowerShell
Overview
The Get-Clipboard
command retrieves the contents of the system’s clipboard, the temporary storage location for copied data. It is primarily used to access text, images, or other data that has been previously copied or cut.
Syntax
Get-Clipboard [-Text] [-Image] [-DataType] [-Format <string>]
Options/Flags
-Text
- Returns only the text content of the clipboard.
- Default:
$false
-Image
- Returns only the image content of the clipboard.
- Default:
$false
-DataType
- Retrieves the data type of the clipboard contents.
- Default:
System.String
-Format
- Specifies the format of the output.
- Available values:
Text
,Image
,DataType
- Default:
Text
for text content,Image
for image content,DataType
for data type
Examples
Get clipboard text
Get-Clipboard -Text
Get clipboard image
Get-Clipboard -Image
Get clipboard data type
Get-Clipboard -DataType
Customize output format
# Get clipboard image in PNG format
Get-Clipboard -Image -Format PNG
Common Issues
Clipboard is empty
If the clipboard has no content, the command will return an empty string.
Integration
Get-Clipboard
can be integrated with other commands to perform advanced tasks, such as:
- Save clipboard image to a file:
Get-Clipboard -Image -Format PNG | Set-Content -Path "ClipboardImage.png"
Related Commands
Set-Clipboard
: Sets the contents of the clipboard.Clear-Clipboard
: Clears the contents of the clipboard.