@@ -106,7 +106,6 @@ Describe "JEA session Transcript script test" -Tag @("Feature", 'RequireAdminOnW
106106 Unregister-PSSessionConfiguration - Name JEA - Force - ErrorAction SilentlyContinue
107107 }
108108 }
109-
110109}
111110
112111Describe " JEA session Get-Help test" - Tag @ (" CI" , ' RequireAdminOnWindows' ) {
@@ -155,6 +154,34 @@ Describe "JEA session Get-Help test" -Tag @("CI", 'RequireAdminOnWindows') {
155154 Remove-Item $RoleCapDirectory - Recurse - Force - ErrorAction SilentlyContinue
156155 }
157156 }
157+
158+ It " Get-Help should throw <ExpectedError> on <command>" - TestCases (Get-HelpNetworkTestCases ) {
159+ param (
160+ $Command ,
161+ $ExpectedError
162+ )
163+
164+ [string ] $RoleCapDirectory = (New-Item - Path " $TestDrive \RoleCapability" - ItemType Directory - Force).FullName
165+ [string ] $PSSessionConfigFile = " $RoleCapDirectory \TestConfig.pssc"
166+ $configurationName = ' RestrictedWithNoGetHelpProxy'
167+ try
168+ {
169+ New-PSSessionConfigurationFile - Path $PSSessionConfigFile `
170+ - SessionType Empty `
171+ - LanguageMode NoLanguage `
172+ - ModulesToImport ' Microsoft.PowerShell.Utility' , ' Microsoft.PowerShell.Core' `
173+ - VisibleCmdlets ' Get-command' , ' measure-object' , ' select-object' , ' enter-pssession' , ' get-formatdata' , ' out-default' , ' out-file' , ' exit-pssession' , ' get-help'
174+ Register-PSSessionConfiguration - Name $configurationName - Path $PSSessionConfigFile - Force - ErrorAction SilentlyContinue
175+ $scriptBlock = [scriptblock ]::Create(" Get-Help -Name $Command " )
176+ {Invoke-Command - ConfigurationName $configurationName - ComputerName localhost - ScriptBlock $scriptBlock - ErrorAction Stop} |
177+ Should - Throw - ErrorId $ExpectedError
178+ }
179+ finally
180+ {
181+ Unregister-PSSessionConfiguration - Name $configurationName - Force - ErrorAction SilentlyContinue
182+ Remove-Item $RoleCapDirectory - Recurse - Force - ErrorAction SilentlyContinue
183+ }
184+ }
158185}
159186
160187Describe " Remoting loopback tests" - Tags @ (' CI' , ' RequireAdminOnWindows' ) {
@@ -358,6 +385,7 @@ Describe "Remoting loopback tests" -Tags @('CI', 'RequireAdminOnWindows') {
358385 $session = New-RemoteSession - ConfigurationName $endPoint
359386 try {
360387 $result = Invoke-Command - Session $session - ScriptBlock { $Host.Version }
388+ Write-Verbose " host version: $result " - Verbose
361389 $result | Should - Be $PSVersionTable.PSVersion
362390 }
363391 finally {
0 commit comments