简体   繁体   English

Powershell - 在模块中找到命令,但无法加载模块

[英]Powershell - command was found in the module, but the module could not be loaded

I am using let's encrypt certificate and azure key vault to automate renewal process using this repo: https://github.com/brent-robinson/posh-acme-azure-example我正在使用让我们加密证书和 azure 密钥库来使用此存储库自动更新过程: https://github.com/brent-robinson/posh-acme-azure-example

I have installed the module Az.KeyVault using yaml on azure devops pipeline:我已经在 azure devops 管道上使用 yaml 安装了模块 Az.KeyVault:

# Install the Az PowerShell modules our script will need
- task: PowerShell@2
  displayName: Install PowerShell Modules (Az.Accounts, Az.KeyVault, Az.Resources, Posh-ACME)
  inputs:
    targetType: 'inline'
    script: 'Install-Module Az.Accounts, Az.KeyVault, Az.Resources, Posh-ACME -Force'
    errorActionPreference: 'stop'
    failOnStderr: true
    pwsh: true

But, when I run the script, getting the below error:但是,当我运行脚本时,出现以下错误:

The 'Get-AzKeyVaultCertificate' command was found in the
     | module 'Az.KeyVault', but the module could not be loaded. For
     | more information, run 'Import-Module Az.KeyVault'.

When I try to add the import module ( Import-Module -Name Az.KeyVault -Force ) it's giving the below error:当我尝试添加导入模块( Import-Module -Name Az.KeyVault -Force )时,出现以下错误:

Assembly with the same name is already loaded

There is an issue with the latest version of Posh-ACME module (4.15.0).最新版本的 Posh-ACME 模块 (4.15.0) 存在问题。 Install version 4.14.0 to resolve this.安装版本 4.14.0 以解决此问题。

Install-Module -Name Posh-ACME -RequiredVersion 4.14.0 -Force

Ref: https://github.com/brent-robinson/posh-acme-azure-example/issues/15#issuecomment-1241850416参考: https://github.com/brent-robinson/posh-acme-azure-example/issues/15#issuecomment-1241850416

When you try to install the module in CI/CD pipeline you can specify the user so that it won't conflict with other.当您尝试在 CI/CD 管道中安装模块时,您可以指定用户,以免与其他用户发生冲突。

#install Az PowerShell Modules with Specific User
- task: PowerShell@2
  displayName: Install PowerShell Modules (Az.Accounts, Az.KeyVault, Az.Resources, Posh-ACME)
  inputs:
    targetType: 'inline'
    script: 'Install-Module Az.Accounts, Az.KeyVault, Az.Resources, Posh-ACME -Force CurrentUser' 

The 'Get-AzKeyVaultCertificate' command was found in the | 'Get-AzKeyVaultCertificate' 命令位于 | module 'Az.KeyVault', but the module could not be loaded.模块“Az.KeyVault”,但无法加载该模块。 For |对于 | more information, run 'Import-Module Az.KeyVault'.更多信息,请运行“Import-Module Az.KeyVault”。

Assembly with the same name is already loaded已加载同名程序集

The error messages show that Az keyVault was already installed but not able to load in a pipeline to run task.错误消息显示Az keyVault已安装但无法加载到管道中以运行任务。 You can specify the user (Current user or all user) to install the required module to specific user and import the required module .您可以指定用户(当前用户或所有用户)将所需模块安装到特定用户并导入所需模块

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure Powershell 模块中找到命令,但是模块无法加载 - Azure Powershell Command was found in the module, but the module could not be loaded 显示“在模块中找到命令,但无法加载模块”的错误消息。 - Error message that says "Command was found in the module, but the module could not be loaded." Azure Functions Powershell:无法通过托管依赖项加载模块 - Azure Functions Powershell: module could not be loaded via managed dependencies Import-Module:未加载指定的模块“ msonline”,因为在任何模块目录中均未找到有效的模块文件 - Import-Module : The specified module 'msonline' was not loaded because no valid module file was found in any module directory 要导入以运行此 Powershell 命令的模块的名称 - Name of module to be imported to run this Powershell Command Import-Module AzureRM Import-Module:未加载指定的模块'AzureRM',因为在任何模块目录中均未找到有效的模块文件 - Import-Module AzureRM Import-Module : The specified module 'AzureRM' was not loaded because no valid module file was found in any module directory Powershell remove-mfa PS 命令所需的模块 - Powershell module needed for remove-mfa PS command Azure RM PowerShell模块中的Enable-AzStorageStaticWebsite命令 - Enable-AzStorageStaticWebsite command in Azure RM PowerShell module PowerShell 安装模块命令在 Azure DevOps 管道中失败 - PowerShell Install-Module Command fails in Azure DevOps Pipeline 在Powershell中安装Azure模块 - Azure module installation in Powershell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM