Set-Clipboard

Set the current Windows clipboard entry.

Syntax
      Set-Clipboard [-Append] [-AsHtml] [-Confirm] -LiteralPath String[] [-WhatIf] [CommonParameters]

      Set-Clipboard [-Append] [-AsHtml] [-Confirm] -Path String[] [-WhatIf] [CommonParameters]

      Set-Clipboard [-Value] String[] [-Append] [-AsHtml] [-Confirm] [-WhatIf] [CommonParameters]

Key
   -Append
       Do not clear the clipboard but append content to it.

   -AsHtml
       Render the content as HTML to the clipboard.

   -LiteralPath String[]
       The path to the item that will be copied to the clipboard.
       Unlike Path, the value of LiteralPath is used exactly as it is typed.
       No characters are interpreted as wildcards.
       If the path includes escape characters, enclose it in single quotation marks this will
       tell PowerShell not to interpret any characters as escape sequences.

   -Path String[]
       The path to the item that will be copied to the clipboard.
       Wildcard characters are permitted.

   -Value String[] 
        Specify, as a string array, the content to copy to the clipboard.

   -Confirm
       Prompt for confirmation before running the cmdlet.

   -WhatIf
       Describe what would happen if you executed the command without actually executing it.

Standard Aliases for Set-Clipboard: clip.

When using Set-Clipboard in a script you should warn the user that their clipboard is about to be overwritten.

When piping a PowerShell object to Set-Clipboard it is often helpful to first convert the object/collection to a string with out-string.

Examples

Copy some text to the clipboard:

PS C:\> Set-Clipboard -Value "This is a test string"
or
PS C:\>"This is a test string" | Set-Clipboard

Copy the current date to the clipboard:

PS C:\> Get-date | Set-Clipboard

Copy the current date to the clipboard, but first convert the date to a string giving a more verbose date format:

PS C:\> Get-date | out-string | Set-Clipboard

Copy the contents of a directory to the clipboard:

PS C:\> Set-Clipboard -Path "C:\Staging\"

“A clipboard and a hard hat could get you just about anywhere” ~ Kim Harrison

Related PowerShell Cmdlets:

Get-Clipboard - Get the current Windows clipboard entry.


 
Copyright © 1999-2022 SS64.com
Some rights reserved