Search code examples
powershellclipboard

PowerShell 6.2.4 : Get-Clipboard' is not recognized as the name of a cmdlet


I would expect Get-Clipboard to work from this

I am on PowerShell 6.2.4 and 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

Solution

  • PowerShell [Core] v6.x has no clipboard cmdlets - you'll have to wait for v7.0 for them to return (the available preview releases have them).

    The documentation URL in your link ends in ?view=powershell-7, indicating a v7.x topic; there's a dropdown list labeled "Version" to select a different PowerShell version; if you had selected 6, you would have been told that no such page exists for v6.x

    In the meantime, you have two options:

    • Use platform-specific tools such as pbpaste / pbcopy (macOS) and xclip (Linux distros with X11-based desktop), and clip.exe / the System.Windows.Forms assembly on Windows.

    • Use the ClipboardText third-party module (authored by me; repo), which wraps the above tools for you (text support only, via commands Set-ClipboardText and Get-ClipboardText).

      • The module also works with Windows PowerShell versions v2-v4, which similarly lack clipboard utilities.