PowerShell / PowerShell/PowerShell
$PSVersionTable does not correctly implement ToString, causing issues with Set-Clipboard
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 55.5k
- Forks
- 8.5k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 88
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
Since #18116 has been implemented, I have tried to use it when filling out issues on my remote setup, but I need to pipe it via Out-String for it to work properly. This seems to be caused by it not implementing ToString() correctly, instead relying on formatters to display its information.
Expected behavior
> $PSVersionTable | Set-Clipboard
> Get-Clipboard # Ctrl+Shift+V
Name Value
---- -----
PSVersion 7.4.0-preview.4
PSEdition Core
GitCommitId 7.4.0-preview.4
OS Ubuntu 22.04.2 LTS
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Actual behavior
> $PSVersionTable | Set-Clipboard
> Get-Clipboard
System.Management.Automation.PSVersionHashTable
Error details
No response
Environment data
Name Value
---- -----
PSVersion 7.4.0-preview.4
PSEdition Core
GitCommitId 7.4.0-preview.4
OS Ubuntu 22.04.2 LTS
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported pipeline with $PSVersionTable, Set-Clipboard, and Get-Clipboard, then trace the PSVersionHashTable type and its string conversion behavior. Done means piping $PSVersionTable directly to Set-Clipboard produces the formatted name-and-value output shown under Expected behavior, without requiring Out-String.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, powershell
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100