从微软文档手册中,我找到了PowerShell的“Get-剪贴板”选项。
选项是“-生源”:
-Raw :获取剪贴板的全部内容。多行文本返回为单个多行字符串,而不是字符串数组。
但是我找不到添加“-生源”的区别。
例如,
powershell.exe "Get-Clipboard -Format text " > MyText.txt
和
powershell.exe "Get-Clipboard -Format text -Raw" > MyText.txt
给出同样的结果。(不管剪贴板的内容如何),你能给我举个例子,让'-Raw‘选项的使用产生不同的效果吗?
发布于 2021-07-15 19:37:06
$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
正如它所说的,它是一个字符串,而不是一个字符串数组。
这里有一个例子说明了很多次这件事的重要性。
$text = Get-Clipboard
$text -match 'different'
different lines
$text = Get-Clipboard -Raw
$text -match 'different'
true
https://stackoverflow.com/questions/68399808
复制相似问题