Today I implemented a JEA solution in PowerShell, but at the customer site we hit an error which I did not see in our test environments.
When we tried to execute Import-PSSession we got this error:
Running the Get-Command command in a remote session reported the following error: A parameter cannot be found that matches parameter name ‘PowerShellVersion’
Searching the net found this issue in github for PS6.0, but there is no information around a fix in PS5.1
https://github.com/PowerShell/PowerShell/issues/4195
I asked my friend Aleksandar Nikolic and he suggested to try and make a workaround for Get-FormatData. So we did, and we managed to make it work!
Workaround:
1. Open your role capability file
2. Make Get-FormatData cmdlet visible
# Cmdlets to make visible when applied to a session VisibleCmdlets = 'Search-Alerts','Get-FormatData'
3. Define a alias for the Get-formatdata function
# Aliases to be defined when applied to a session AliasDefinitions = @{ Name='Get-FormatData' Value='Microsoft.PowerShell.Utility\Get-FormatData' }
[…] Source: CTGlobal […]
Doing this allows scripts to execute the full function and bypass the proxy function. The proxy function is there to enforce the security boundary, so it seems that doing this would make the constrained endpoint unsafe.
Thanks a lot for this (The original Github report does not list the solution). I missed the part about opening the capability file, because I was creating it using powershell (New-PSRoleCapabilityFile), but managed to get there with some trial and error.