获取 Powershell 的剪贴板:'-Raw' 选项?

imi*_*a k 3 clipboard powershell command-line text

从微软文档手册中,我找到了 PowerShell 的“Get-Clipboard”选项。
选项是 '-Raw' :

-Raw :获取剪贴板的全部内容。多行文本作为单个多行字符串而不是字符串数组返回。

但是我找不到添加“-Raw”的任何区别。
例如,

powershell.exe "Get-Clipboard -Format text " > MyText.txt
Run Code Online (Sandbox Code Playgroud)

powershell.exe "Get-Clipboard -Format text -Raw" > MyText.txt
Run Code Online (Sandbox Code Playgroud)

给出相同的结果。(不管剪贴板的内容如何)你能给我举个例子,让'-Raw'选项的使用有所不同吗?

Dou*_*rer 5

$tempfile = New-TemporaryFile

@'
some 
different lines 
of text
'@ | Set-Content $tempfile

Get-Content $tempfile | Set-Clipboard

$text = Get-Clipboard

$text.count

3

$text = Get-Clipboard -Raw

$text.Count

1
Run Code Online (Sandbox Code Playgroud)

正如它所说,它是一个字符串,而不是一个字符串数组。

这是多次重要的一个例子。

$text = Get-Clipboard

$text -match 'different'

different lines

$text = Get-Clipboard -Raw

$text -match 'different'

true
Run Code Online (Sandbox Code Playgroud)