Restricted Language? Error trying to import module

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

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

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

Did you confirm you were in full language mode with

$ExecutionContext.SessionState.LanguageMode

 

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

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

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.

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