Invoke command in Constrained Language mode

Welcome Forums General PowerShell Q&A Invoke command in Constrained Language mode

Viewing 1 reply thread
  • Author
    • #238754
      Topics: 68
      Replies: 72
      Points: 543
      Rank: Major Contributor

      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

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

      PS C:\Utility> .\TestScript.ps1

      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: (:) [], RuntimeException
      + FullyQualifiedErrorId : MethodInvocationNotSupportedInConstrainedLanguage
      + PSComputerName : w19-sanfe02



    • #240116
      Senior Moderator
      Topics: 9
      Replies: 1309
      Points: 4,781
      Helping Hand
      Rank: Community Hero

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

      PowerShell Constrained Language Mode

      • This reply was modified 2 months, 2 weeks ago by kvprasoon. Reason: post correction
Viewing 1 reply thread
  • You must be logged in to reply to this topic.