今天之前,我已经配置了这一管道并投入了工作。 然而,根据最近对该单元的更新,我现在发现这一错误。
Write-Error: This module requires Az.Accounts version 2.19.0. An earlier version of
Az.Accounts is imported in the current PowerShell session. Please open a new
session before importing this module. This error could indicate that multiple
incompatible versions of the Azure PowerShell cmdlets are installed on your
system. Please see https://aka.ms/azps-version-error for troubleshooting
information.
我试图在模块文字中添加这一内容,以删除现有的文字,并安装新的版本2.19.0。 no
$desiredVersion = "2.19.0"
$installedModule = Get-InstalledModule -Name "Az.Accounts" -ErrorAction SilentlyContinue
Write-Output "$($installedModule)"
if ($installedModule) {
if ($installedModule.Version.ToString() -ne $desiredVersion) {
Uninstall-Module -Name "Az.Accounts" -Force -ErrorAction SilentlyContinue
Install-Module -Name "Az.Accounts" -RequiredVersion $desiredVersion -Force -AllowClobber -Scope CurrentUser -Repository PSGallery
}
} else {
Install-Module -Name "Az.Accounts" -RequiredVersion $desiredVersion -Force -AllowClobber -Scope CurrentUser -Repository PSGallery
}
Import-Module Az.Accounts