powershell - PowerShell 6.2.4:Get-Clipboard' 未被识别为 cmdlet 的名称
问题描述
我希望Get-Clipboard
从这个工作
我使用的是 PowerShell 6.2.4 和 MacOs Catalina?
Get-Clipboard : The term 'Get-Clipboard' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At /Users/.../debug.ps1:41 char:1
+ Get-Clipboard
+ ~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-Clipboard:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
解决方案
PowerShell [Core] v6.x没有剪贴板 cmdlet - 您必须等待 v7.0才能返回(可用的预览版本有它们)。
链接中的文档 URL 以结尾?view=powershell-7
,表示 v7.x 主题;有一个标有“版本”的下拉列表可以选择不同的 PowerShell 版本;如果您选择了6
,您会被告知 v6.x 不存在此类页面
与此同时,您有两种选择:
使用特定于平台的工具,例如
pbpaste
/pbcopy
(macOS) 和xclip
(带有基于 X11 桌面的 Linux 发行版)和clip.exe
/System.Windows.Forms
Windows 上的程序集。使用
ClipboardText
第三方模块(由我编写;repo),它为您包装了上述工具(仅文本支持,通过命令Set-ClipboardText
和Get-ClipboardText
)。- 该模块还适用于Windows PowerShell 版本 v2-v4,它们同样缺少剪贴板实用程序。
推荐阅读
- sas - MDX 语句 - 跳过级别
- windows - 如何在 Windows 上安装 Agda 标准库?
- generics - 如何在使用泛型的类中将操作应用于泛型类型
- java - 使用 Mockito Mock 的 Apache Camel Route 的 JUnit 测试不会失败
- bash - 如何检查文件是否完整并到达 EOF?
- stored-procedures - 带有文本类型的 SAP HANA 存储过程可选输出参数
- html - 根据 if 语句添加类
- sql-server - SSIS 包日期格式
- node.js - 在 express 和 Mongoose 中的 findOne() 中嵌套 json 对象
- deep-learning - MNIST 数据集上 PyTorch 中的张量形状不匹配错误,但在合成数据上没有错误