Restricted Language? Error trying to import module

Welcome Forums General PowerShell Q&A Restricted Language? Error trying to import module

  • This topic has 5 replies, 2 voices, and was last updated 1 month ago by
    Participant
    .
Viewing 5 reply threads
  • Author
    Posts
    • #224322
      Participant
      Topics: 36
      Replies: 59
      Points: 133
      Rank: Participant

      I am trying to import Don Jones’ “EnhancedHTML2” module. I downloaded the files from GitHub and copied them to my Modules folder (my server doesn’t have access to external sites). When I try to import the module, I receive an error about the module manifest. Error is below. I am in “FullLanguage” mode (not constrained/restricted). I have seen sites when researching this error, but have found no solution yet. Any ideas?

       

      Error:

      Test-ModuleManifest : The module manifest
      ‘C:\Windows\system32\WindowsPowerShell\v1.0\Modules\EnhancedHTML2\EnhancedHTML2.psd1’ could not be processed because
      it is not a valid Windows PowerShell restricted language file. Remove the elements that are not permitted by the
      restricted language:
      At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\EnhancedHTML2\EnhancedHTML2.psd1:1 char:1
      + $script = ”
      + ~~~~~~~~~~~~
      Assignment statements are not allowed in restricted language mode or a Data section.
      At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\EnhancedHTML2\EnhancedHTML2.psd1:1 char:1
      + $script = ”
      + ~~~~~~~
      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, $null, $PSScriptRoot, $PSEdition.
      At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\EnhancedHTML2\EnhancedHTML2.psd1:2 char:1
      + function ConvertTo-EnhancedHTML {
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Function declarations are not allowed in restricted language mode or a Data section.
      At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\EnhancedHTML2\EnhancedHTML2.psd1:2 char:33
      + function ConvertTo-EnhancedHTML {
      + ~
      Script block literals are not allowed in restricted language mode or a Data section.
      At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\EnhancedHTML2\EnhancedHTML2.psd1:61 char:5
      + param(
      + ~~~~~~
      Parameter declarations are not allowed in restricted language mode or a Data section.
      At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\EnhancedHTML2\EnhancedHTML2.psd1:60 char:5
      + [CmdletBinding()]
      + ~~~~~~~~~~~~~~~~~
      Attributes are not allowed in restricted language mode or a Data section.
      At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\EnhancedHTML2\EnhancedHTML2.psd1:62 char:17
      + [string]$jQueryURI = ‘http://ajax.aspnetcdn.com/ajax/jQuery/j
      + ~~~~~~~~~~
      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, $null, $PSScriptRoot, $PSEdition.
      At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\EnhancedHTML2\EnhancedHTML2.psd1:63 char:17
      + [string]$jQueryDataTableURI = ‘http://ajax.aspnetcdn.com/ajax
      + ~~~~~~~~~~~~~~~~~~~
      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, $null, $PSScriptRoot, $PSEdition.
      At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\EnhancedHTML2\EnhancedHTML2.psd1:64 char:9
      + [Parameter(ParameterSetName=’CSSContent’)][string[]]$CssStyle …
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Attributes are not allowed in restricted language mode or a Data section.
      At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\EnhancedHTML2\EnhancedHTML2.psd1:64 char:61
      + … [Parameter(ParameterSetName=’CSSContent’)][string[]]$CssStyleSheet,
      + ~~~~~~~~~~~~~~
      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, $null, $PSScriptRoot, $PSEdition.
      Not all parse errors were reported. Correct the reported errors and try again.
      At line:1 char:1
      + Test-ModuleManifest C:\Windows\system32\WindowsPowerShell\v1.0\Module …
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo : ResourceUnavailable: (C:\Windows\syst…ancedHTML2.psd1:String) [Test-ModuleManifest], M
      issingMemberException
      + FullyQualifiedErrorId : Modules_InvalidManifest,Microsoft.PowerShell.Commands.TestModuleManifestCommand

    • #224382
      Participant
      Topics: 3
      Replies: 340
      Points: 1,120
      Helping Hand
      Rank: Community Hero

      Did you confirm you were in full language mode with

      $ExecutionContext.SessionState.LanguageMode

       

    • #224394
      Participant
      Topics: 36
      Replies: 59
      Points: 133
      Rank: Participant

      Yes. I am in FullLanguage mode. I have never updated that setting.

    • #224397
      Participant
      Topics: 3
      Replies: 340
      Points: 1,120
      Helping Hand
      Rank: Community Hero

      Right, but just for sanity sake, you ran that?

    • #224400
      Participant
      Topics: 3
      Replies: 340
      Points: 1,120
      Helping Hand
      Rank: Community Hero

      OK try this. Instead of downloading from github, download the nuget package from here

      Extract the package like a zip file, I used 7-zip. Then copy/import them. This package worked when the one from Github did not.

      I hope this helps.

    • #224424
      Participant
      Topics: 36
      Replies: 59
      Points: 133
      Rank: Participant

      That worked! Strange – Seems like the contents switched over from the psd1 to the psm1. Either way, working now. Thanks

Viewing 5 reply threads
  • You must be logged in to reply to this topic.