Skip to content
Permalink
live
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
external help file Locale Module Name ms.date online version schema title
Microsoft.PowerShell.Commands.Management.dll-Help.xml
en-US
Microsoft.PowerShell.Management
08/03/2021
2.0.0
Set-Clipboard

Set-Clipboard

SYNOPSIS

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 to the clipboard. In this example, we are getting a public ssh key so that it 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 does not clear the clipboard and appends content to it.

Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
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: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Value

The string values to be added to the clipboard.

Type: System.String[]
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

System.String[]

OUTPUTS

NOTES

In rare cases when using Set-Clipboard with a high number of values in rapid succession, like in a loop, you might sporadically get a blank value from the clipboard. This can be fixed by using Start-Sleep -Milliseconds 1 in the loop.

RELATED LINKS

Get-Clipboard