Invoke command in Constrained Language mode

I have a server that is running in Constrained Language Mode which is enforced via GPO. I have a script which I have signed and will run if I run on the server.

PS C:\Utility> hostname
W19-SANFE02

PS C:\Utility> $ExecutionContext.SessionState.LanguageMode
ConstrainedLanguage

PS C:\Utility> .\TestScript.ps1
Hello

I am trying to run this same script from a remote server from which I have domain admin credentials to authenticate with. The error comes back that it is in the Constrained Language mode.

Is there a way to accomplish the execution of this signed script in this fashion? Want to run a similar script on multiple servers.

PS H:\Scripts> Invoke-Command -ComputerName w19-sanfe02 -FilePath .\TestScript.ps1 -Credential XXXX\brian.clanton
Cannot invoke method. Method invocation is supported only on core types in this language mode.
+ CategoryInfo : InvalidOperation: (:slight_smile: , RuntimeException
+ FullyQualifiedErrorId : MethodInvocationNotSupportedInConstrainedLanguage
+ PSComputerName : w19-sanfe02

 

 

Not sure, but below link would give you some clue in “Then what is it for?” section.