New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import-PSSession fails with ParameterBindingException if it is running with PowerShell 5.1 #4195

ryhayash opened this Issue Jul 7, 2017 · 5 comments


Copy link

ryhayash commented Jul 7, 2017

Steps to reproduce

[Server Side (PowerShell 5.1)]
New-PSSessionConfigurationFile -Path .\TestSession.pssc -SessionType RestrictedRemoteServer -LanguageMode NoLanguage
Register-PSSessionConfiguration -Name TestSession -Path .\TestSession.pssc
Restart-Service WinRM

[Client Side (PowerShell 5.1)]
$credential = Get-Credential
$session = New-PSSession -ComputerName ServerName -Credential $credential -ConfigurationName TestSession
Import-PSSession $session <--- This will fail.

This doesn't happen if client is PowerShell 5.0 or lower version.


[Debug note]
I took iDNA trace for wsmprovhost.exe on server side and here is the error path. 

This happens if client powershell is 5.1 or above as a parameter ‘PowerShellVersion’ is added to argument for Get-FormatData wchich is called internally in the Import-PSSession. Then, "Get-FormatData -TypeName xx -PowerShellVersion 5.1" is performed in wsmprovhost.exe on server side. But, 'PowerShellVersion' is marked as unbound parameter in the RestrictedRemoteServer session. Then, ParameterBindingException is thrown from VerifyArgumentsProcessed().

0:005> sxe clr
0:005> g
(a04.8dc): CLR exception - code e0434352 (first/second chance not available)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
Time Travel Position: 3F0A400000001
00007ff8`d4dea110 4055 push rbp

0:021> !pe
Exception object: 000001cc1c0bdf00
Exception type: System.Management.Automation.ParameterBindingException
StackTrace (generated):

HResult: 80131501

0:021> !mk
ESP RetAddr
00:U 0000009567abd758 00007ff8d4dea110 ntdll!RtlRaiseException
01:U 0000009567abd760 00007ff8d1cf7788 kernelbase!RaiseException+0x68
02:U 0000009567abd840 00007ff8b937047a clr!RaiseTheExceptionInternalOnly+0x2aa
03:U 0000009567abd940 00007ff8b93705ea clr!IL_Throw+0x10b
04:M 0000009567abdaf0 00007ff8b4252363 System.Management.Automation.CmdletParameterBinderController.VerifyArgumentsProcessed(System.Management.Automation.ParameterBindingException)(+0x121 IL)(+0x0 Native)
05:M 0000009567abdbb0 00007ff8b424ec8d System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(System.Collections.ObjectModel.Collection1<System.Management.Automation.CommandParameterInternal>)(+0x15b IL)(+0x0 Native) 06:M 0000009567abdc50 00007ff8b424e6aa System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(System.Collections.ObjectModel.Collection1<System.Management.Automation.CommandParameterInternal>)(+0x1a IL)(+0x69 Native)
07:M 0000009567abdcd0 00007ff8b424e464 System.Management.Automation.CommandProcessor.BindCommandLineParameters()(+0x38 IL)(+0x14d Native)
08:M 0000009567abdd30 00007ff8b424c94a System.Management.Automation.CommandProcessorBase.DoPrepare(System.Collections.IDictionary)(+0x1e IL)(+0x43 Native)

Expected behavior

You can use imported the following commands.

・Clear-Host (cls, clear)
・Exit-PSSession (exsn, exit)
・Get-Command (gcm)
・Measure-Object (measure)
・Select-Object (select)

Actual behavior

Receive the following error when running Import-PSSession.

Import-PSSession : Running the Get-Command command in a remote session reported the following error: A parameter cannot be found that matches parameter name 'PowerShellVersion'.

Environment data

This issue occurs only with PowerShell 5.1.


This comment has been minimized.

Copy link

iSazonov commented Jul 7, 2017

Thank you for your report and analysis!


This comment has been minimized.

Copy link

SteveL-MSFT commented Jul 7, 2017

This appears to be the area of the problem:

// For remote PS version 5.1 and greater, we need to include the new -PowerShellVersion parameter

@SteveL-MSFT SteveL-MSFT added this to the 6.0.0-HighPriority milestone Jul 7, 2017

@PaulHigin PaulHigin self-assigned this Jul 10, 2017


This comment has been minimized.

Copy link

PaulHigin commented Jul 10, 2017

This is a regression bug. In PS 5.1 we added a requirement to implicit remoting where Get-FormatData must support a "PowerShellVersion" parameter, but we neglected to include it as an approved parameter for a restricted session.


This comment has been minimized.

Copy link

mirichmo commented Jul 11, 2017

Is there a TFS bug for this? If so, please add the TFS bug # here to cross-reference it.


This comment has been minimized.

Copy link

PaulHigin commented Jul 11, 2017

Yes. Here is the TFS bug 12717061.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment