Set remoting PSVersionTable private data in a downlevel compatible manner

This commit is contained in:
Jason Shirk (POWERSHELL) 2016-08-02 09:36:58 -07:00
parent 2b74b89f76
commit 2b70837d98
2 changed files with 12 additions and 1 deletions

View file

@ -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;

View file

@ -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;