CommandCompletion in RestrictedRemoteServer session config

by shuvalov at 2013-03-24 05:12:31

Hello. I was wondering for a way to implement tab expansion in RestrictedRemoteServer session type endpoints.
I know there are workarounds like Default session type and limiting everything in it or startup script like this
I’m looking a way to find why running following code
[System.Management.Automation.CommandCompletion]::CompleteInput(‘get-comm’, 8, $null)
inside Default session return CompletionMatches data and running code in RestrictedRemoteServer return empty CompletionMatches.
Both session have LanguageMode = FullLanguage and if I create child powershell instance using
$ps = ]
I can run completion for this instance using CompleteInput
[System.Management.Automation.CommandCompletion]::CompleteInput(‘get-comm’, 8, $null, $ps)
So its look like CommandCompletion cant access current <code> instance in RestrictedRemoteServer session.</code></code></code></blockquote>by DonJ at 2013-03-24 06:19:05<blockquote>Correct, and Full language is - as you note - a workaround. Albeit a clumsy one for what you're trying to do.</blockquote>by shuvalov at 2013-03-24 06:44:24<blockquote>[quote=&quot;DonJ&quot;]Correct, and Full language is - as you note - a workaround. Albeit a clumsy one for what you're trying to do.[/quote]<br>Using CompleteInput with <code>::Create() isnt workaround in real as it will expand command available in child runspace, not those available in current endpoint runspace. So it will expand all default commands even those not available for user and not expand any custom commands loaded in endpoint.
Furthermore after some testing I found that if I call modified TabExpansion2 function with ::create() in it will return CompletionMatches but powershell host will ignore it.
by shuvalov at 2013-05-06 02:47:06
Just to let everyone know.
I got confirmation from MS support that this is by design and not yet documented due to documentation bug. So TabCompletion not going to work in any RestrictedRemoteServer endpoint.
For related functionality (
) there is an explicit acknowledgement of this.