20

I'm having an issue with Azure PS modules. I have installed via PS gallery with the following:

Install-Module AzureRM
Install-Module Azure

(And restarted)

However, when I run Login-AzureRmAccount I get the following error:

Login-AzureRmAccount : The term 'Login-AzureRmAccount' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + Login-AzureRmAccount + ~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Login-AzureRmAccount:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

I seem to have all of the Azure Modules installed. I.e. if I run Get-Module -List I get following.

Script     3.7.0      Azure                               {Get-AzureAutomationCertificate, Get-AzureAutomationConnec...
Script     0.1.0      Azure.AnalysisServices              {Add-AzureAnalysisServicesAccount, Restart-AzureAnalysisSe...
Script     2.7.0      Azure.Storage                       {Get-AzureStorageTable, New-AzureStorageTableSASToken, New...
Script     3.7.0      AzureRM                             {Update-AzureRM, Import-AzureRM, Uninstall-AzureRM, Instal...
Script     0.1.0      AzureRM.AnalysisServices            {Resume-AzureRmAnalysisServicesServer, Suspend-AzureRmAnal...
Script     3.5.0      AzureRM.ApiManagement               {Add-AzureRmApiManagementRegion, Get-AzureRmApiManagementS...
Script     2.7.0      AzureRM.Automation                  {Get-AzureRMAutomationHybridWorkerGroup, Get-AzureRmAutoma...
Script     2.7.0      AzureRM.Backup                      {Backup-AzureRmBackupItem, Enable-AzureRmBackupContainerRe...
Script     2.7.0      AzureRM.Batch                       {Remove-AzureRmBatchAccount, Get-AzureRmBatchAccount, Get-...
Script     2.7.0      AzureRM.Cdn                         {Get-AzureRmCdnProfile, Get-AzureRmCdnProfileSsoUrl, New-A...
Script     0.5.0      AzureRM.CognitiveServices           {Get-AzureRmCognitiveServicesAccount, Get-AzureRmCognitive...
Script     2.8.0      AzureRM.Compute                     {Remove-AzureRmAvailabilitySet, Get-AzureRmAvailabilitySet...
Script     2.7.0      AzureRM.DataFactories               {Remove-AzureRmDataFactory, Get-AzureRmDataFactoryRun, Get...
Script     2.7.0      AzureRM.DataLakeAnalytics           {Get-AzureRmDataLakeAnalyticsDataSource, New-AzureRmDataLa...
Script     3.5.0      AzureRM.DataLakeStore               {Get-AzureRmDataLakeStoreTrustedIdProvider, Remove-AzureRm...
Script     2.7.0      AzureRM.DevTestLabs                 {Get-AzureRmDtlAllowedVMSizesPolicy, Get-AzureRmDtlAutoShu...
Script     2.7.0      AzureRM.Dns                         {Get-AzureRmDnsRecordSet, New-AzureRmDnsRecordConfig, Remo...
Script     0.1.0      AzureRM.EventHub                    {New-AzureRmEventHubKey, Get-AzureRmEventHubNamespace, Get...
Script     2.7.0      AzureRM.HDInsight                   {Get-AzureRmHDInsightJob, New-AzureRmHDInsightSqoopJobDefi...
Script     2.7.0      AzureRM.Insights                    {Get-AzureRmUsage, Get-AzureRmMetricDefinition, Get-AzureR...
Script     1.3.0      AzureRM.IotHub                      {Add-AzureRmIotHubKey, Get-AzureRmIotHubEventHubConsumerGr...
Script     2.7.0      AzureRM.KeyVault                    {Add-AzureKeyVaultCertificate, Set-AzureKeyVaultCertificat...
Script     2.7.0      AzureRM.LogicApp                    {Get-AzureRmIntegrationAccountAgreement, Get-AzureRmIntegr...
Script     0.12.0     AzureRM.MachineLearning             {Move-AzureRmMlCommitmentAssociation, Get-AzureRmMlCommitm...
Script     0.4.0      AzureRM.Media                       {Sync-AzureRmMediaServiceStorageKeys, Set-AzureRmMediaServ...
Script     3.6.0      AzureRM.Network                     {Add-AzureRmApplicationGatewayAuthenticationCertificate, G...
Script     2.7.0      AzureRM.NotificationHubs            {Get-AzureRmNotificationHub, Get-AzureRmNotificationHubAut...
Script     2.7.0      AzureRM.OperationalInsights         {New-AzureRmOperationalInsightsAzureActivityLogDataSource,...
Script     2.7.0      AzureRM.PowerBIEmbedded             {Remove-AzureRmPowerBIWorkspaceCollection, Get-AzureRmPowe...
Script     2.7.0      AzureRM.profile                     {Disable-AzureRmDataCollection, Enable-AzureRmDataCollecti...
...

Hope someone is able to help? Running on Windows Server 2012 R2 with Powershell 4

Regards

Nagoh
  • 813
  • 2
  • 10
  • 23
  • Oddly, using `Add-AzureRmAccount` works fine. Still a bit confused at to why this is happening – Nagoh Mar 20 '17 at 04:18
  • What is your Azure PowerShell version? You could use the cmdlet to check `Get-Module -ListAvailable -Name Azure -Refresh`. – Shui shengbao Mar 20 '17 at 04:29
  • PS v4. That command returns: `ModuleType Version Name ExportedCommands ---------- ------- ---- ---------------- Script 3.7.0 Azure {Get-AzureAutomationCertificate, Get-AzureAutomationConnec...` – Nagoh Mar 20 '17 at 04:56
  • Sorry for my mistake, you version is latest. If possible, I suggest you could try to install Azure PowerShell by using `*.msi`. In my answer, I give you the link. After you install it, you could try again. – Shui shengbao Mar 20 '17 at 05:00
  • I test in my lab, my azure PowerShell `ModuleType` is `Manifest`, your is `Script`. – Shui shengbao Mar 20 '17 at 05:05
  • Yeah - I have tried by both MSI and Gallery. Rebooted after each install / uninstall. – Nagoh Mar 20 '17 at 05:20
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/138494/discussion-between-walter-msft-and-nagoh). – Shui shengbao Mar 20 '17 at 05:20
  • Please check for the steps in this link. Hope this helps !! https://stackoverflow.com/a/45682031/1907955 – Srikanth Popuri Aug 14 '17 at 20:13

5 Answers5

18

You need to Update to a new version of Azure PowerShell.

  • Use the Command:

Install-Module AzureRM -AllowClobber

Reference Article: https://learn.microsoft.com/en-us/powershell/azure/install-azurerm-ps

Clavin Fernandes
  • 724
  • 7
  • 10
  • 1
    I believe the correct option instead of AllowClobber is now Force – blizz Aug 30 '17 at 19:34
  • 1
    The command "Install-Module AzureRM -AllowClobber" should work and the AllowClobber seems to be valid with reference to article: https://learn.microsoft.com/en-us/powershell/azure/install-azurerm-ps – Clavin Fernandes Nov 11 '17 at 04:22
  • 4
    The term 'Install-Module' is not recognized as the name of a cmdlet... sigh – TxRegex Jan 09 '18 at 22:22
  • The term "The term 'Install-Module' is not recognized as the name of a cmdlet.." Solution can be found at : https://stackoverflow.com/questions/41585758/install-module-the-term-install-module-is-not-recognized-as-the-name-of-a-cm – Clavin Fernandes Jan 10 '18 at 12:15
4

You could use the latest Azure Power Shell version from the link.

Notes: Please install 3.7.0 version.

enter image description here

RajeshKdev
  • 6,365
  • 6
  • 58
  • 80
Shui shengbao
  • 18,746
  • 3
  • 27
  • 45
1

For me, Install-Module was not recognized, and I already had Azure 3.7 installed, the answer was to install Azure CLI 2.0 for Windows

MrLore
  • 3,759
  • 2
  • 28
  • 36
0

I had this problem when running a Powershell script as a scheduled task (using a user profile reserved for running scheduled tasks) but not when running from the Powershell prompt interactively as an administrator. (I was using Powershell version 5.1.)

Get-Module -List seemed to be telling me that the required AzureRm modules were already installed for all users (under C:\Program Files\WindowsPowerShell\Modules). Nevertheless it seemed as if they were not installed for the task user.

I put a setup routine in my scheduled task to run the following commands in the context of my task:

Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-Module AzureRM.Dns -Scope AllUsers -RequiredVersion 4.0.1 -AcceptLicense

(version 4.0.1 being what appeared to be installed already).

I also had to use Install-Module PowershellGet -Force to get the 'Scope' parameter of Install-Module to be accepted. Wasn't clear which of these three commands finally did the trick.

Daz
  • 2,833
  • 2
  • 23
  • 30
0

I faced a similar problem after I installed the Az module in Powershell. In a particular session, PowerShell can run either Rm commands or Az commands.

To Run RM commands:

  • Open a new Powershell window.
  • Re-install AzureRM module using the command:

Install-Module "AzureRM"

  • Run the Rm command as usual.

Hope this solves your problem.

Sheena Agrawal
  • 700
  • 1
  • 7
  • 15