MLogdberg / APIManagementARMTemplateCreator

Azure API Management Template Extractor, extracts ARM templates for your API's to be used in the CI/CD process.
MIT License
45 stars 43 forks source link

The 'Get-APIManagementTemplate' command was found in the module, but the module could not be loaded #130

Open melix-dev opened 1 year ago

melix-dev commented 1 year ago

The latest version 1.4.200 of APIManagementTemplate results in an error when imported in Powershell 5.

Information:

PS C:\WINDOWS\system32> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.22621.1778
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22621.1778
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

PS C:\WINDOWS\system32> Get-InstalledModule -Name APIManagementTemplate

Version              Name                                Repository           Description
-------              ----                                ----------           -----------
1.4.200              APIManagementTemplate               PSGallery            Extract Azure API Management to ARM templates

PS C:\WINDOWS\system32> Import-Module -Name APIManagementTemplate -Debug
VERBOSE: Loading module from path 'C:\Program
Files\WindowsPowerShell\Modules\APIManagementTemplate\1.4.200\APIManagementTemplate.psd1'.

Confirm
Continue with this operation?
[Y] Yes  [A] Yes to All  [H] Halt Command  [S] Suspend  [?] Help (default is "Y"): A
VERBOSE: Cannot verify the Microsoft .NET Framework version 4.5.2 because it is not included in the list of permitted
versions.
VERBOSE: Populating RepositorySourceLocation property for module APIManagementTemplate.
VERBOSE: Loading module from path 'C:\Program
Files\WindowsPowerShell\Modules\APIManagementTemplate\1.4.200\APIManagementTemplate.dll'.
Import-Module : Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral,
PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
At line:1 char:1
+ Import-Module -Name APIManagementTemplate -Debug
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.ImportModuleCommand

If I downgrade to the previous version, it works again in powershell 5 (see below):

PS C:\WINDOWS\system32> Install-Module -Name APIManagementTemplate -RequiredVersion 1.4.197
PS C:\WINDOWS\system32> Get-InstalledModule -Name APIManagementTemplate -AllVersions

Version              Name                                Repository           Description
-------              ----                                ----------           -----------
1.4.197              APIManagementTemplate               PSGallery            Extract Azure API Management to ARM te...

PS C:\WINDOWS\system32> Import-Module -Name APIManagementTemplate -Debug
VERBOSE: Loading module from path 'C:\Program
Files\WindowsPowerShell\Modules\APIManagementTemplate\1.4.197\APIManagementTemplate.psd1'.

Confirm
Continue with this operation?
[Y] Yes  [A] Yes to All  [H] Halt Command  [S] Suspend  [?] Help (default is "Y"): A
VERBOSE: Cannot verify the Microsoft .NET Framework version 4.5.2 because it is not included in the list of permitted
versions.
VERBOSE: Populating RepositorySourceLocation property for module APIManagementTemplate.
VERBOSE: Loading module from path 'C:\Program
Files\WindowsPowerShell\Modules\APIManagementTemplate\1.4.197\APIManagementTemplate.dll'.
VERBOSE: Exporting cmdlet 'Get-ParameterTemplate'.
VERBOSE: Exporting cmdlet 'Write-APIManagementTemplates'.
VERBOSE: Exporting cmdlet 'Get-APIManagementTemplate'.
VERBOSE: Importing cmdlet 'Get-APIManagementTemplate'.
VERBOSE: Importing cmdlet 'Get-ParameterTemplate'.
VERBOSE: Importing cmdlet 'Write-APIManagementTemplates'.

I did not run into this issue with the latest version of APIManagementTemplate module (1.4.200) in Powershell Core. If more information is needed, please let me know.

qfyra commented 1 year ago

I've got the same issue. Downgrading to 1.4.197 helped.

twinpiloot commented 8 months ago

Alternatively, you can use pwsh instead of powershell