Skip to content

Adding again CLRVersion to $PSVersionTable #26948

@theuserbl

Description

@theuserbl

Prerequisites

Steps to reproduce

Adding the .NET Version as CLRVersion in $PSVersionTable.

I have already mentioned it at
#21122
There it was refered to
#19121
which is because of six month inactivity closed.

To say it now more clear: For me it is not a feature or idea to add CLRVersion. It is a bug, that it don't exists.

Can PowerShell be used without .NET? No? Then the .NET version should be included in the $PSVersionTable.

Does the .NET version affect which .NET features are available to me in PowerShell? Yes? Then the .NET version should be included in the $PSVersionTable.

Did Windows PowerShell display the .NET Framework version in the $PSVersionTable? Yes? Then, for compatibility reasons, the .NET version should also be displayed as "CLRVersion".

Here how $PSVersionTable looks with the Windows PowerShell 5.1.26100.6899

PS C:\Users\theuserbl> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.26100.6899
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.26100.6899
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1


PS C:\Users\theuserbl>

Old workaround of me:
Adding in file of $PROFILE the line

$PSVersionTable.CLRVersion = [System.Runtime.InteropServices.RuntimeInformation]::FrameworkDescription -split '\s' | select -Last 1

Current, better workaround:
Adding in file of $PROFILE the line

$PSVersionTable.CLRVersion = [System.Environment]::Version

Yes, this is still only a workaround. The bugfix have to be added in PowerShell direct.

It's a shame that so many PowerShell versions have been released without a CLRVersion.

Expected behavior

`
PS C:\Users\theuserbl> $PSVersionTable

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

PS C:\Users\theuserbl>
`

Actual behavior

`
PS C:\Users\theuserbl> $PSVersionTable

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

PS C:\Users\theuserbl>
`

Error details

CLRVersion is not shown in $PSVersionTable

Environment data

`
PS C:\Users\theuserbl> $PSVersionTable

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

PS C:\Users\theuserbl>
`

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions