AzureAD / MSAL.PS

MIT License
159 stars 29 forks source link

Optimize module for "ConstrainedLanguage" #50

Open hahazeMSFT opened 2 years ago

hahazeMSFT commented 2 years ago

Currently can't import module in ConstrainedLanguage mode.

PS C:\WINDOWS\system32> $ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage"
PS C:\WINDOWS\system32> Import-Module MSAL.PS -Verbose
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\MSAL.PS\4.37.0.0\MSAL.PS.psd1'.
VERBOSE: Populating RepositorySourceLocation property for module MSAL.PS.
Import-Module : Importing *.ps1 files as modules is not allowed in ConstrainedLanguage mode.
At line:1 char:1
+ Import-Module MSAL.PS -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (:) [Import-Module], InvalidOperationException
    + FullyQualifiedErrorId : Modules_ImportPSFileNotAllowedInConstrainedLanguage,Microsoft.PowerShell.Commands.Import
   ModuleCommand
jazuntee commented 2 years ago

I think there are several reasons the module will not work in ConstrainedLanguage mode at the moment. I'll keep this open as something to investigate but it would like require significant rework, if it is even possible.