gpt4 book ai didi

azure - Azure 门户中的 Powershell : This module requires Az. 帐户版本 2.12.5。在当前 PowerShell session 中导入早期版本的 Az.Accounts

转载 作者:行者123 更新时间:2023-12-03 01:59:28 25 4
gpt4 key购买 nike

请求 Cloud Shell。已成功。连接终端...

Import-Module: /opt/microsoft/powershell/7/profile.ps1:13
Line |
13 | Microsoft.PowerShell.Core\Import-Module -Name PSCloudShellUtility
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| This module requires Az.Accounts version 2.12.5. 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.
Import-Module: /opt/microsoft/powershell/7/profile.ps1:26
Line |
26 | Microsoft.PowerShell.Core\Import-Module Az.Tools.Predictor -Force
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Assembly with same name is already loaded
InvalidOperation: /opt/microsoft/powershell/7/profile.ps1:308
Line |
308 | & ($script:PSCloudShellUtilityModuleInfo){Get-CloudShellTip -ErrorAct …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, a script block, or a CommandInfo object.
VERBOSE: Authenticating to Azure ...
InvalidOperation: /opt/microsoft/powershell/7/profile.ps1:64
Line |
64 | & ($script:PSCloudShellUtilityModuleInfo){param([string]$Label, [ …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, a script block, or a CommandInfo object.
Invoke-CloudShellTelemetry: /opt/microsoft/powershell/7/profile.ps1:95
Line |
95 | Invoke-CloudShellTelemetry -LogLabel "GETSUBSCRIPTIONID" -Sta …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, a script block, or a CommandInfo object.
InvalidOperation: /opt/microsoft/powershell/7/profile.ps1:64
Line |
64 | & ($script:PSCloudShellUtilityModuleInfo){param([string]$Label, [ …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, a script block, or a CommandInfo object.
InvalidOperation: /opt/microsoft/powershell/7/profile.ps1:64
Line |
64 | & ($script:PSCloudShellUtilityModuleInfo){param([string]$Label, [ …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, a script block, or a CommandInfo object.
InvalidOperation: /opt/microsoft/powershell/7/profile.ps1:64
Line |
64 | & ($script:PSCloudShellUtilityModuleInfo){param([string]$Label, [ …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, a script block, or a CommandInfo object.
Import-Module: /opt/microsoft/powershell/7/profile.ps1:395
Line |
395 | Microsoft.PowerShell.Core\Import-Module -Name AzurePSDrive
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| This module requires Az.Accounts version 2.12.5. 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.
VERBOSE: Building your Azure drive ...
InvalidOperation: /opt/microsoft/powershell/7/profile.ps1:64
Line |
64 | & ($script:PSCloudShellUtilityModuleInfo){param([string]$Label, [ …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, a script block, or a CommandInfo object.
New-PSDrive: /opt/microsoft/powershell/7/profile.ps1:406
Line |
406 | $null = Microsoft.PowerShell.Management\New-PSDrive -Name Azure - …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot find a provider with the name 'SHiPS'.
WARNING: Something went wrong while creating Azure drive. You can still use this shell to run Azure PowerShell commands.
InvalidOperation: /opt/microsoft/powershell/7/profile.ps1:64
Line |
64 | & ($script:PSCloudShellUtilityModuleInfo){param([string]$Label, [ …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, a script block, or a CommandInfo object.
InvalidOperation: /opt/microsoft/powershell/7/profile.ps1:419
Line |
419 | & ($script:PSCloudShellUtilityModuleInfo){Set-CloudShellPSReadLineKey …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, a script block, or a CommandInfo object.
InvalidOperation: /opt/microsoft/powershell/7/profile.ps1:64
Line |
64 | & ($script:PSCloudShellUtilityModuleInfo){param([string]$Label, [ …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, a script block, or a CommandInfo object.
PS /home/kumari> Get-Module Az.Accounts

ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 2.9.1 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}

PS /home/user> update-Module -Name Az.Accounts -RequiredVersion 2.12.5
Install-Package: Unable to find repository '/usr/cloudshell/temp'. Use Get-PSRepository to see all available repositories.

最佳答案

错误原因:如果 Az.Accounts 版本已加载到 PowerShell session 中,则该版本无法替换为更新版本,在github里说的很清楚文档。

需要检查以下内容:

要验证当前 Powershell 模块中安装的 Az.accounts 版本,请使用

Get-InstalledModule Az.Accounts -AllVersions

它在输出中显示所有加载的版本,如图所示。现在,在 PSModulePath 中,识别不同目录中 Az.Accounts 的多个条目。

enter image description here

如果您在输出数据中看到任何旧版本,只需删除不在全局范围 %ProgramFiles%PowerShellModules 中的版本即可。只需访问路径 C:user>DocumentsPowerShellModulesAz.Accounts 删除模块目录即可删除模块。

更多详细信息请参见github文档。

并且

安装或导入模块时,使用-RequiredVersion标志。以便 PowerShell session 获取当前模块版本数据并相应地执行它。

Import-Module -Name Az.Accounts -RequiredVersion 2.12.5

查看 Powershell Gallery 中模块数据的最新版本.

如果问题仍然存在,请关闭当前 PowerShell session 并再次运行 cmdlet。

您还可以在此处查看 incompatibilities简单地介绍一下问题。

关于azure - Azure 门户中的 Powershell : This module requires Az. 帐户版本 2.12.5。在当前 PowerShell session 中导入早期版本的 Az.Accounts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76958908/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com