header image

Clipboard cmdlets

Posted by: | November 26, 2019 Comments Off on Clipboard cmdlets |

The clipboard cmdlets return in PowerShell v7 preview 6

Get-Clipboard and Set-Clipboard are back and according to the release notes work cross platform.

PS> Get-Command Get-Clipboard -Syntax

Get-Clipboard [-Raw] [<CommonParameters>]

 

PS> Get-Clipboard
Clipboard test

 

The Raw parameter makes Get-Clipboard ignore new line characters and get the entire contents of the clipboard.

PS> Get-Clipboard -Raw
Clipboard test

Clipboard test2

 

Putting values onto the clipboard:

PS> Get-Command Set-Clipboard -Syntax

Set-Clipboard [-Value] <string[]> [-Append] [-WhatIf] [-Confirm] [<CommonParameters>]

 

PS> Set-Clipboard -Value ‘new clipboard’ –Append

PS> Get-Clipboard -Raw
Clipboard test

Clipboard test2
new clipboard

 

The clipboard can be cleared – more or less – with a blank string

Set-Clipboard -Value ‘ ‘

 

On Linux, Set-Clipboard requires the xclip utility to be in the path.

under: PowerShell 7

Comments are closed.

Categories