From 7d49b2938b8df4f553d8d1715de5f01c8f51bdaa Mon Sep 17 00:00:00 2001 From: Thomas Nieto <38873752+ThomasNieto@users.noreply.github.com> Date: Tue, 25 Feb 2020 10:38:41 -0600 Subject: [PATCH 1/2] Fix PSEdition format --- .../DefaultFormatters/PowerShellCore_format_ps1xml.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs b/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs index 09cc323b936..b9e3df7a6c1 100644 --- a/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs +++ b/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs @@ -1655,9 +1655,17 @@ private static IEnumerable ViewsOf_ModuleInfoGrouping(Cust .AddScriptBlockColumn(@" $result = [System.Collections.ArrayList]::new() $editions = $_.CompatiblePSEditions + if (-not $editions) { - $editions = @('Desktop') + if ($_.PrivateData -and ($_.PrivateData.PSData.Tags -contains 'PSEdition_Desktop' -or + $_.PrivateData.PSData.Tags -contains 'PSEdition_Core')) + { + $editions = @(($_.PrivateData.PSData.Tags | Where-Object {$_ -like 'PSEdition_*'}) -replace 'PSEdition_', '') + } + else { + $editions = @('Desktop') + } } foreach ($edition in $editions) From 1028e7280834dd789d01a04c89e8f81864ebfda6 Mon Sep 17 00:00:00 2001 From: Thomas Nieto <38873752+ThomasNieto@users.noreply.github.com> Date: Tue, 25 Feb 2020 12:02:49 -0600 Subject: [PATCH 2/2] Add logic for $PSHOME and Windows PowerShell --- .../PowerShellCore_format_ps1xml.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs b/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs index b9e3df7a6c1..90b7d7ad7b8 100644 --- a/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs +++ b/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs @@ -1658,14 +1658,21 @@ private static IEnumerable ViewsOf_ModuleInfoGrouping(Cust if (-not $editions) { - if ($_.PrivateData -and ($_.PrivateData.PSData.Tags -contains 'PSEdition_Desktop' -or + if ($_.PrivateData -and ($_.PrivateData.PSData.Tags -contains 'PSEdition_Desktop' -or $_.PrivateData.PSData.Tags -contains 'PSEdition_Core')) { $editions = @(($_.PrivateData.PSData.Tags | Where-Object {$_ -like 'PSEdition_*'}) -replace 'PSEdition_', '') } - else { + elseif ($_.ModuleBase -like '{0}*' -f $PSHOME) { + $editions = @('Core') + } + elseif ($IsWindows -and + $_.ModuleBase -like '{0}\Windows\system32\WindowsPowerShell\v1.0\Modules' -f $Env:SystemDrive ) { $editions = @('Desktop') } + else { + $editions = @() + } } foreach ($edition in $editions) @@ -1673,7 +1680,7 @@ private static IEnumerable ViewsOf_ModuleInfoGrouping(Cust $result += $edition.Substring(0,4) } - ($result | Sort-Object) -join ','") + if ($result) { ($result | Sort-Object) -join ','}") .AddScriptBlockColumn("$_.ExportedCommands.Keys") .EndRowDefinition() .EndTable());