I have a module which is imported into WinRM session which is in RestrictedLanguage mode. I need to get ErrorOutput stream from following command
$output = Receive-job * -ErrorVariable RemoteErr
This does not work since in RestrictedLanguage mode this variable is not allowed and fails with error below
A variable that cannot be referenced in restricted language mode or a Data section is being referenced. Variables that can be referenced include the following: $PSCulture, $PSUICulture, $true, $false, and $null.
Short of switching Remote Session configuration to ConstrainedLanguage what are my options?