powershell - Powershell 5剪贴板-手动粘贴 “complex”剪贴板内容不起作用

标签 powershell powershell-5.0

我刚刚在笔记本上安装了Win10,并首先查看了所有新的Commandlet。

使用以下简单文本时:

PS C:\Users\SudoSandwich> $do = echo "sad"
PS C:\Users\SudoSandwich> $do | Set-Clipboard

然后手动将其粘贴到记事本中就可以了,但是我遇到了一些“复杂”剪贴板内容的问题。
让我们使用dir | Set-Clipboard
我知道您必须在控制台中使用Get-Clipboard -Format FileDropList来取回它,但是将dir的结果粘贴到记事本中怎么办?在这种情况下,显然粘贴被禁用。

有人知道为什么这还行不通吗?在控制台中选择输出并将其粘贴到记事本中的老式方法仍然可以正常工作。

最佳答案

您可以使用Out-String cmdlet将任何复杂对象转换为通常在控制台上看到的文本。然后,您可以将该文本复制到剪贴板:

dir | Out-String | Set-Clipboard

关于powershell - Powershell 5剪贴板-手动粘贴 “complex”剪贴板内容不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34191677/

相关文章:

powershell - Azure VHD 备份?

powershell 在 MetroUI 中创建应用程序组

azure - 如何在 PowerShell 中使用 AzModule 命令创建 AzureProfile.json 文件?

Powershell 5 : documentation support via comments for classes and enums members

powershell - Import-Module 仅在从 Get-Module 进行管道传输时才有效

windows - 在Powershell中通过7zip命令提取.zip时如何处理CRC错误?

powershell - 当将Select-Object与First参数一起使用时,OutVariable包含不正确的数据

windows - 更改硬盘唯一ID

powershell - PowerShell变量 `${$}`, `${^}`和 `$?`

json - 在Powershell中合并JSON对象