Set-Clipboard
Sets the contents of the clipboard.
Syntax
Set-Clipboard
-Value <String[]>
[-Append]
[-WhatIf]
[-Confirm]
[-PassThru]
[<CommonParameters>]
Description
The Set-Clipboard
cmdlet sets the contents of the clipboard.
Note
On Linux, this cmdlet requires the xclip
utility to be in the path.
Examples
Example 1: Copy text to the clipboard
Set-Clipboard -Value "This is a test string"
Example 2: Copy the contents of a file to the clipboard
This example pipes the contents of a file, a public ssh key, to the clipboard. Then, the key can be pasted into another application, like GitHub.
Get-Content C:\Users\user1\.ssh\id_ed25519.pub | Set-Clipboard
Parameters
-Append
Indicates that the cmdlet should add to the clipboard instead of replacing it. By default, the cmdlet clears the current content from the clipboard and sets it to the new content. When this parameter is specified, the cmdlet appends the new content after a newline to the current content.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Confirm
Prompts you for confirmation before running the cmdlet.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-PassThru
Returns an object representing the item with which you're working. By default, this cmdlet does not generate any output.
Type: | SwitchParameter |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Value
The string values to be added to the clipboard.
Type: | String[] |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet isn't run.
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Inputs
You can pipe a string containing the content to set to the clipboard to this cmdlet.
Outputs
None
This cmdlet returns no output.
Notes
PowerShell includes the following aliases for Set-Clipboard
:
- All platforms:
scb