Invoke command in Constrained Language mode

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

Viewing 1 reply thread
  • Author
    Posts
    • #238754
      Participant
      Topics: 67
      Replies: 71
      Points: 527
      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
      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: (:) [], RuntimeException
      + FullyQualifiedErrorId : MethodInvocationNotSupportedInConstrainedLanguage
      + PSComputerName : w19-sanfe02

       

       

    • #240116
      Senior Moderator
      Topics: 9
      Replies: 1244
      Points: 4,480
      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 1 week, 5 days ago by kvprasoon. Reason: post correction
Viewing 1 reply thread
  • You must be logged in to reply to this topic.