mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Set remoting PSVersionTable private data in a downlevel compatible manner
This commit is contained in:
@@ -81,6 +81,14 @@ namespace System.Management.Automation
|
||||
return s_psVersionTable;
|
||||
}
|
||||
|
||||
internal static Hashtable GetPSVersionTableForDownLevel()
|
||||
{
|
||||
var result = (Hashtable)s_psVersionTable.Clone();
|
||||
// Downlevel systems don't support SemanticVersion, but Version is most likely good enough anyway.
|
||||
result[PSVersionInfo.PSVersionName] = (Version)(SemanticVersion)s_psVersionTable[PSVersionInfo.PSVersionName];
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static Version GetBuildVersion()
|
||||
{
|
||||
string assemblyPath = typeof(PSVersionInfo).GetTypeInfo().Assembly.Location;
|
||||
|
||||
@@ -6438,7 +6438,10 @@ namespace System.Management.Automation
|
||||
{
|
||||
result = new PSPrimitiveDictionary();
|
||||
}
|
||||
PSPrimitiveDictionary versionTable = new PSPrimitiveDictionary(PSVersionInfo.GetPSVersionTable());
|
||||
PSPrimitiveDictionary versionTable = new PSPrimitiveDictionary(PSVersionInfo.GetPSVersionTableForDownLevel())
|
||||
{
|
||||
{"PSSemanticVersion", PSVersionInfo.PSVersion.ToString()}
|
||||
};
|
||||
result.Add(PSVersionInfo.PSVersionTableName, versionTable);
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user