diff --git a/src/System.Management.Automation/engine/InitialSessionState.cs b/src/System.Management.Automation/engine/InitialSessionState.cs index e174393603..8551c81bfb 100644 --- a/src/System.Management.Automation/engine/InitialSessionState.cs +++ b/src/System.Management.Automation/engine/InitialSessionState.cs @@ -4253,6 +4253,11 @@ param( [switch] ${ShowWindow}) + # Display the full help topic by default but only for the AllUsersView parameter set. + if (($psCmdlet.ParameterSetName -eq 'AllUsersView') -and !$Full) { + $PSBoundParameters['Full'] = $true + } + #Set the outputencoding to Console::OutputEncoding. More.com doesn't work well with Unicode. $outputEncoding=[System.Console]::OutputEncoding diff --git a/test/powershell/engine/Help/HelpSystem.Tests.ps1 b/test/powershell/engine/Help/HelpSystem.Tests.ps1 index c872b7a5d1..c1f34823e9 100644 --- a/test/powershell/engine/Help/HelpSystem.Tests.ps1 +++ b/test/powershell/engine/Help/HelpSystem.Tests.ps1 @@ -278,7 +278,7 @@ Describe "Get-Help should find pattern help files" -Tags "CI" { } } - Describe "Get-Help should find pattern alias" -Tags "CI" { +Describe "Get-Help should find pattern alias" -Tags "CI" { # Remove test alias AfterAll { Remove-Item alias:\testAlias1 -ErrorAction SilentlyContinue @@ -300,5 +300,21 @@ Describe "Get-Help should find pattern help files" -Tags "CI" { $help.Category | Should BeExactly "Alias" $help.Synopsis | Should BeExactly "Where-Object" } +} +Describe "help function uses full view by default" -Tags "CI" { + It "help should return full view without -Full switch" { + $gpsHelp = (help Microsoft.PowerShell.Management\Get-Process) + $gpsHelp | Where-Object {$_ -cmatch '^PARAMETERS'} | Should Not BeNullOrEmpty + } + + It "help should return full view even with -Full switch" { + $gpsHelp = (help Microsoft.PowerShell.Management\Get-Process -Full) + $gpsHelp | Where-Object {$_ -cmatch '^PARAMETERS'} | Should Not BeNullOrEmpty + } + + It "help should not append -Full when not using AllUsersView parameter set" { + $gpsHelp = (help Microsoft.PowerShell.Management\Get-Process -Parameter Name) + $gpsHelp | Where-Object {$_ -cmatch '^PARAMETERS'} | Should BeNullOrEmpty + } }