How to fix Az.accounts in powershell as its not loading the latest version 2.12.2

Amriteshwar Singh 30 Reputation points
2023-05-02T20:25:36.88+00:00
Line |
  13 |  Microsoft.PowerShell.Core\Import-Module -Name PSCloudShellUtility
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | This module requires Az.Accounts version 2.12.2. 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.

---------------------------------------------------
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, [ …
Windows for business | Windows Server | User experience | PowerShell
Microsoft Security | Microsoft Entra | Microsoft Entra ID
{count} vote

2 answers

Sort by: Most helpful
  1. JamesTran-MSFT 36,906 Reputation points Microsoft Employee Moderator
    2023-05-15T19:54:51.24+00:00

    @Amriteshwar Singh

    Thank you for your post and I apologize for the delayed response!

    Error Message:

    Line |
      13 |  Microsoft.PowerShell.Core\Import-Module -Name PSCloudShellUtility
         |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         | This module requires Az.Accounts version 2.12.2. 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
    

    To hopefully help resolve your issue or point you in the right direction, I'll share some troubleshooting steps below.

    1. Referencing your error message, please close out of all your PS sessions and retry importing the PSCloudShellUtility module.
    2. If you're still having issues, ensure you have the latest version of Az.Accounts, or the version required to use the PSCloudShellUtility module. You can check for it using Get-Module Az.Accounts
    3. Update the module as needed - Update-Module -Name "ModuleName" -Force
    4. If updating your module and restarting your PS sessions don't help resolve your issue, you can Uninstall the Az module and re-install it, to ensure you have everything required to lever the PSCloudShellUtility module.

    I hope this helps!

    If you have any other questions or are still having issues, please let me know. Thank you for your time and patience throughout this issue.


    If the information helped address your question, please Accept the answer. This will help us and also improve searchability for others in the community who might be researching similar information.

    1 person found this answer helpful.

  2. Rich Matheisen 47,901 Reputation points
    2023-05-02T21:14:35.6833333+00:00

    Install the version 2.12.2

    Install-Module -Name Az.Accounts -RequiredVersion 2.12.2
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.