English 中文(简体)
由于AZ,Dopops输油管无法运行。 管理系统FT更新账户模块
原标题:Azure Devops pipeline failing due to AZ.Accounts Module update by MSFT

今天之前,我已经配置了这一管道并投入了工作。 然而,根据最近对该单元的更新,我现在发现这一错误。

“Console输出”/

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
问题回答

可在Azure PowerShell 任务之前添加一个PowerShell,任务是安装该模块Az.Accounts 2.19.0。 参见下文。

stages:
- stage: A
  jobs:
  - job: A1
    pool:
      vmImage: ubuntu-latest
    steps:
    - task: PowerShell@2
      displayName:  Install Module Az.Accounts 
      inputs:
        pwsh: true
        targetType:  inline 
        script:  Install-Module -Name Az.Accounts -RequiredVersion 2.19.0 -Repository PSGallery -Force 
    
    - task: AzurePowerShell@5
      displayName:  Check Module Az.Accounts 
      inputs:
        pwsh: true
        azureSubscription:  myArmConnection 
        ScriptType:  InlineScript 
        Inline:  Get-InstalledModule -Name "Az.Accounts" 
        azurePowerShellVersion:  LatestVersion 

“entergraph





相关问题
Mutually exclusive powershell parameters

SCENARIO I m writing a cmdlet for Powershell 2.0 using Visual Studio 2008 and .NET 3.5 the cmdlet requires 3 arguments. my intended grammar of the cmdlet is something like this: cmdletname [foo|...

Run a program from PowerShell with timeout

I ll write a script that runs a program and wait for it finished. But if the program is not finished within a specified time I want that the program is killed.

How to transpose data in powershell

I have a file that looks like this: a,1 b,2 c,3 a,4 b,5 c,6 (...repeat 1,000s of lines) How can I transpose it into this? a,b,c 1,2,3 4,5,6 Thanks

Powershell v2 remoting and delegation

I have installed Powershell V2 on 2 machines and run Enable-PsRemoting on both of them. Both machines are Win 2003 R2 and are joined to the same active directory domain and I can successfully run ...

PowerShell -match operator and multiple groups

I have the following log entry that I am processing in PowerShell I m trying to extract all the activity names and durations using the -match operator but I am only getting one match group back. I m ...

热门标签