question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Set-Clipboard is missing -AsHtml

See original GitHub issue

Prerequisites

Steps to reproduce

Set-Clipboard is missing -AsHtml in PS 7+

There is no known workaround or alternative for this incredibly useful feature.

Expected behavior

"<table><tr><td>Test</td><td>Test</td></tr></table>" | Set-Clipboard -AsHtml 

Should produce a table for any rich-text enabled Office application (Word, Outlook, OneNote) and maybe other applications that understand this.

Actual behavior

-AsHtml does not exist. Piping into |ConvertTo-Html does not work

Plain-text paste: <table><tr><td>Test</td><td>Test</td></tr></table>

Error details

Set-Clipboard: A parameter cannot be found that matches parameter name 'AsHtml'.

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.6
PSEdition                      Core
GitCommitId                    7.2.6
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:21 (8 by maintainers)

github_iconTop GitHub Comments

4reactions
jhoneillcommented, Oct 3, 2022

PowerShell 7 on Windows should have parity with Windows PowerShell 5.

I don’t understand why the PowerShell team won’t just take the necessary code from Windows Powershell and use it? Or is Microsoft just a name, and the project has nothing to do with the corporation?

There are two primary reasons (a) The code is something which cannot be open sourced, for whatever reason and (b) for some reason it was supported in .NET Framework but is not longer available in current .NET (and WHY? is a valid question there). Clipboard support went away in V6 for .NET related reasons, and came back in V7; I think in V7 it may be different code, or possibly just the subset of code which works cross platform . Sometimes teams in Microsoft do re-invent the wheel rather than using something from another group, but I don’t think is what is happening here.

2reactions
SteveL-MSFTcommented, Oct 3, 2022

I believe the reasoning on why this no longer exists has been answered. I would also encourage folks to publish a clipboard module to PSGallery whether it’s Windows only or, preferably, cross-platform. The built-in one as part of PS7 is intentionally limited to have it cross-platform.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Set-Clipboard (Microsoft.PowerShell.Management)
Indicates that the cmdlet renders the content as HTML to the clipboard. Type: SwitchParameter. Position: Named. Default value: None. Accept pipeline input: ...
Read more >
How to set clipboard's plain text and html part at the same ...
html" | Set-Clipboard -AsHtml will set the html part and flush the plain text part of clipboard, so that using Get-Clipboard will get...
Read more >
Some short Powershell tips #1
But I just want to paste the data on a sheet somewhere I liked. There is a cool cmdlet called: Set-Clipboard. PS H:\>...
Read more >
Using PowerShell Copy to Clipboard Function
Set-Clipboard Powershell Command. Set-Clipboard replaces clip.exe but behaves exactly the same. Now, instead of piping output to clip, you can ...
Read more >
Set-Clipboard for PowerShell 7
I know the ClipboardText module exists, but I really wanted something that brought back the 'file' copy and paste functionality (as well as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found