Azure powershell error when open

Ishmael Borg 1 Reputation point
2022-10-20T07:10:10.067+00:00

When i open azure powershell from the browser i have this error can anyone help please?

Requesting a Cloud Shell.Succeeded.
Connecting terminal...

Welcome to Azure Cloud Shell

Type "az" to use Azure CLI
Type "help" to learn about 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.10.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.

InvalidOperation: /opt/microsoft/powershell/7/profile.ps1:304
Line |
304 | & ($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:60
Line |
60 | & ($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:91
Line |
91 | 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:60
Line |
60 | & ($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:60
Line |
60 | & ($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:60
Line |
60 | & ($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:391
Line |
391 | Microsoft.PowerShell.Core\Import-Module -Name AzurePSDrive
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| This module requires Az.Accounts version 2.10.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.

VERBOSE: Building your Azure drive ...
InvalidOperation: /opt/microsoft/powershell/7/profile.ps1:60
Line |
60 | & ($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:402
Line |
402 | $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:60
Line |
60 | & ($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:415
Line |
415 | & ($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:60
Line |
60 | & ($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.

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
17,447 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Vasil Michev 85,001 Reputation points MVP
    2022-10-20T08:48:32.45+00:00

    Just remove the corresponding Import-Module cmdlet from your PowerShell profile. Cloud Shell will auto-load the module on its own, no need to add it to the profile.


  2. JamesTran-MSFT 34,031 Reputation points Microsoft Employee
    2022-10-27T21:49:13.237+00:00

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

    Error Message:

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

    As mentioned by @Vasil Michev , you can remove the Import-Module -Name PSCloudShellUtility command since Cloud Shell will load the most up to date modules. If you run into issues executing commands from the PSCloudShellUtility module, you'll typically be prompted to install the module, if needed.

    For example - Troubleshooting & Limitations of Azure Cloud Shell:
    When you run AzureAD cmdlets like "Get-AzureADUser" in Cloud Shell, you might see an error: You must call the "Connect-AzureAD" cmdlet before calling any other cmdlets.

    You can also run get-module to ensure that the PSCloudShellUtility module is installed.
    254874-image.png

    Additional Links:
    Overview of Azure Cloud Shell
    Features & tools for Azure Cloud Shell
    Troubleshooting & Limitations of Azure Cloud Shell

    I hope this helps!

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

    ----------

    Please remember to "Accept Answer" if any answer/reply helped, so that others in the community facing similar issues can easily find the solution.