[英]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.