共用方式為


Get-Clipboard

取得剪貼簿的內容。

語法

Default (預設值)

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

Description

Get-Clipboard Cmdlet 會以文字的形式取得剪貼簿的內容。 多行文字會以類似 Get-Content的字串陣列傳回。

備註

在 Linux 上,此 Cmdlet 需要 xclip 公用程式位於路徑中。 在macOS上,此 Cmdlet 會使用 pbpaste 公用程式。

範例

範例一:取得剪貼簿的內容

Set-Clipboard -Value 'hello world'
Get-Clipboard
hello world

參數

-Raw

取得剪貼簿的整個內容。 多行文字會以單一多行字串的形式傳回,而不是字串陣列。

參數屬性

類型:SwitchParameter
預設值:None
支援萬用字元:False
不要顯示:False

參數集

(All)
Position:Named
必要:False
來自管線的值:False
來自管線按屬性名稱的值:False
來自剩餘引數的值:False

CommonParameters

此 Cmdlet 支援一般參數:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 如需詳細資訊,請參閱 about_CommonParameters

輸入

None

您不能將物件透過管道傳送到此 Cmdlet。

輸出

String

根據預設,此 Cmdlet 會將內容傳回為字串陣列,每行一個。 當您使用 Raw 參數時,它會傳回包含檔案中每一行的單一字串。

備註

PowerShell 包含下列 Get-Clipboard的別名:

  • 所有平臺:
    • gcb

macOS 上的此 Cmdlet 支援已在 PowerShell 7.0.0 版本中新增。