Azure Cloud Shell, The term 'Get-MsolUser' is not recognized as a name of a cmdlet

Sylwester 5 Reputation points
2023-04-12T14:48:43.9366667+00:00

I try to run few PowerShell commands via Cloud Shell. I'm launching Cloud Shell being logged in as global administrator of Office 365, I activates Azure subscription to be able to use powershell in cloud. I need output from:

Get-MsolUser -All | Where {$_.ProxyAddresses -like "smtp:<UPN value>"} | select UserPrincipalName, ImmutableId,proxyaddresses

But I cant get even this working:

Get-MsolUser -All

Solutions I tried already:

PS /home/sylwester> Install-Module -Name AzureAD

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the
modules from 'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): Y

PS /home/sylwester> Import-Module -Name AzureAD
Import-Module: Assembly with same name is already loaded
PS /home/sylwester> Get-Command -Module AzureAD -Name Get-MsolUser
Get-Command: The term 'Get-MsolUser' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
PS /home/sylwester> Get-Module -Name AzureAD -ListAvailable

ModuleType Version PreRelease Name PSEdition ExportedCommands

Binary 2.0.2.140 AzureAD Desk
PS /home/sylwester> Import-Module -Name AzureAD -Force

Untrusted repository

PS /home/sylwester> Import-Module -Name AzureAD -Force

PS /home/sylwester> Get-Command -Module AzureAD -Name Get-MsolUser
The term 'Get-MsolUser' is not recognized as a name of a cmdlet, function
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,329 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. shiva patpi 13,171 Reputation points Microsoft Employee
    2023-04-12T23:47:59.17+00:00

    @Sylwester Instead of using Azure Cloud Shell , can you try using the local powershell window

    Install-Module MSOnline -Force

    Connect-MsolService

    Get-MsolUser

    Below are my tests in cloudshell & Local windows:

    User's image

    1 person found this answer helpful.