Powershell: Can't Uninstall/Remove AzureRM module from PowerShell on Mac OS

Created on 27 Oct 2017  ·  3Comments  ·  Source: PowerShell/PowerShell

Steps to reproduce

First I run the command:

Install-Module` AzureRM -AllowClobber -Scope CurrentUser   

not being aware that I won't be able to use it on my Mac OS Sierr 10.12.6.
When I found issue #4090 I have run the command:

Install-Module` AzureRM.netcore -AllowClobber -Scope CurrentUser 

After that, I still couldn't run

Login-AzureRmAccount 

because still got an error:
Login-AzureRmAccount : The 'Login-AzureRmAccount' command was found in the module 'AzureRM.profile', but the module could not be loaded. For more information, run 'Import-Module AzureRM.profile'.

I have tried uninstalling the AzureRM and AzureRM.netcore module with the following command:

Uninstall-Module AzureRM -AllVersions -Force 
Uninstall-Module AzureRM.netcore -AllVersions -Force 

Then I have tried to install AzureRM.netcore again

Install-Module` AzureRM.netcore -AllowClobber -Scope CurrentUser 

and run the command

Login-AzureRmAccount 

But got exactly the same error.
Login-AzureRmAccount : The 'Login-AzureRmAccount' command was found in the module 'AzureRM.profile', but the module could not be loaded. For more information, run 'Import-Module AzureRM.profile'.
When I run

Import-Module AzureRM.profile   

Got an error:
Import-Module : Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.

I have tried uninstalling the AzureRM and AzureRM.netcore module again with the following command:

Uninstall-Module AzureRM -AllVersions -Force 
Uninstall-Module AzureRM.netcore -AllVersions -Force 

and listed Azure related modules hoping that they are gone, but apparently they haven't been removed:

Get-Module -ListAvailable |Where-Object {$_.Name -like 'AzureRM*'}                                                                                                                         


    Directory: /Users/basia/.local/share/powershell/Modules


ModuleType Version    Name                                ExportedCommands                                                                                                                                 
---------- -------    ----                                ----------------                                                                                                                                 
Script     0.4.7      AzureRM.AnalysisServices            {Resume-AzureRmAnalysisServicesServer, Suspend-AzureRmAnalysisServicesServer, Get-AzureRmAnalysisServicesServer, Remove-AzureRmAnalysisService...
Script     4.4.1      AzureRM.ApiManagement               {Add-AzureRmApiManagementRegion, Get-AzureRmApiManagementSsoToken, New-AzureRmApiManagementHostnameConfiguration, New-AzureRmApiManagementRegi...
Script     3.4.1      AzureRM.Automation                  {Get-AzureRMAutomationHybridWorkerGroup, Get-AzureRmAutomationJobOutputRecord, Import-AzureRmAutomationDscNodeConfiguration, Export-AzureRmAut...
Script     3.4.1      AzureRM.Backup                      {Backup-AzureRmBackupItem, Enable-AzureRmBackupContainerReregistration, Get-AzureRmBackupContainer, Register-AzureRmBackupContainer...}          
Script     3.4.1      AzureRM.Batch                       {Remove-AzureRmBatchAccount, Get-AzureRmBatchAccount, Get-AzureRmBatchAccountKeys, New-AzureRmBatchAccount...}                                   
Script     0.13.7     AzureRM.Billing                     {Get-AzureRmBillingInvoice, Get-AzureRmBillingPeriod}                                                                                            
Script     3.4.1      AzureRM.Cdn                         {Get-AzureRmCdnProfile, Get-AzureRmCdnProfileSsoUrl, New-AzureRmCdnProfile, Remove-AzureRmCdnProfile...}                                         
Script     0.8.7      AzureRM.CognitiveServices           {Get-AzureRmCognitiveServicesAccount, Get-AzureRmCognitiveServicesAccountKey, Get-AzureRmCognitiveServicesAccountSkus, New-AzureRmCognitiveSer...
Script     3.4.1      AzureRM.Compute                     {Remove-AzureRmAvailabilitySet, Get-AzureRmAvailabilitySet, New-AzureRmAvailabilitySet, Update-AzureRmAvailabilitySet...}                        
Manifest   0.9.1      AzureRM.Compute.Netcore             {Remove-AzureRmAvailabilitySet, Get-AzureRmAvailabilitySet, New-AzureRmAvailabilitySet, Update-AzureRmAvailabilitySet...}                        
Script     0.2.7      AzureRM.Consumption                 Get-AzureRmConsumptionUsageDetail                                                                                                                
Script     0.0.2      AzureRM.ContainerInstance           {New-AzureRmContainerGroup, Get-AzureRmContainerGroup, Remove-AzureRmContainerGroup, Get-AzureRmContainerInstanceLog}                            
Script     0.2.7      AzureRM.ContainerRegistry           {New-AzureRmContainerRegistry, Get-AzureRmContainerRegistry, Update-AzureRmContainerRegistry, Remove-AzureRmContainerRegistry...}                
Script     3.4.1      AzureRM.DataFactories               {Remove-AzureRmDataFactory, Get-AzureRmDataFactoryRun, Get-AzureRmDataFactorySlice, Save-AzureRmDataFactoryLog...}                               
Script     0.2.1      AzureRM.DataFactoryV2               {Set-AzureRmDataFactoryV2, Get-AzureRmDataFactoryV2, Remove-AzureRmDataFactoryV2, Set-AzureRmDataFactoryV2LinkedService...}                      
Script     3.4.1      AzureRM.DataLakeAnalytics           {Get-AzureRmDataLakeAnalyticsDataSource, New-AzureRmDataLakeAnalyticsCatalogCredential, Remove-AzureRmDataLakeAnalyticsCatalogCredential, Remo...
Script     4.4.1      AzureRM.DataLakeStore               {Get-AzureRmDataLakeStoreTrustedIdProvider, Remove-AzureRmDataLakeStoreTrustedIdProvider, Remove-AzureRmDataLakeStoreFirewallRule, Set-AzureRm...
Script     3.4.1      AzureRM.DevTestLabs                 {Get-AzureRmDtlAllowedVMSizesPolicy, Get-AzureRmDtlAutoShutdownPolicy, Get-AzureRmDtlAutoStartPolicy, Get-AzureRmDtlVMsPerLabPolicy...}          
Script     3.4.1      AzureRM.Dns                         {Get-AzureRmDnsRecordSet, New-AzureRmDnsRecordConfig, Remove-AzureRmDnsRecordSet, Set-AzureRmDnsRecordSet...}                                    
Script     0.1.1      AzureRM.EventGrid                   {New-AzureRmEventGridTopic, Get-AzureRmEventGridTopic, Set-AzureRmEventGridTopic, New-AzureRmEventGridTopicKey...}                               
Script     0.4.7      AzureRM.EventHub                    {New-AzureRmEventHubKey, Get-AzureRmEventHubNamespace, Get-AzureRmEventHubNamespaceAuthorizationRule, Get-AzureRmEventHubNamespaceKey...}        
Script     3.4.1      AzureRM.HDInsight                   {Get-AzureRmHDInsightJob, New-AzureRmHDInsightSqoopJobDefinition, Wait-AzureRmHDInsightJob, New-AzureRmHDInsightStreamingMapReduceJobDefinitio...
Script     3.4.1      AzureRM.Insights                    {Get-AzureRmUsage, Get-AzureRmMetricDefinition, Get-AzureRmMetric, Remove-AzureRmLogProfile...}                                                  
Script     2.4.1      AzureRM.IotHub                      {Add-AzureRmIotHubKey, Get-AzureRmIotHubEventHubConsumerGroup, Get-AzureRmIotHubConnectionString, Get-AzureRmIotHubJob...}                       
Script     3.4.1      AzureRM.KeyVault                    {Add-AzureKeyVaultCertificate, Set-AzureKeyVaultCertificateAttribute, Stop-AzureKeyVaultCertificateOperation, Get-AzureKeyVaultCertificateOper...
Script     3.4.1      AzureRM.LogicApp                    {Get-AzureRmIntegrationAccountAgreement, Get-AzureRmIntegrationAccountCallbackUrl, Get-AzureRmIntegrationAccountCertificate, Get-AzureRmIntegr...
Script     0.15.7     AzureRM.MachineLearning             {Move-AzureRmMlCommitmentAssociation, Get-AzureRmMlCommitmentAssociation, Get-AzureRmMlCommitmentPlanUsageHistory, Remove-AzureRmMlCommitmentP...
Script     0.1.0      AzureRM.MachineLearningCompute      {Get-AzureRmMlOpCluster, Get-AzureRmMlOpClusterKey, Test-AzureRmMlOpClusterSystemServicesUpdateAvailability, Update-AzureRmMlOpClusterSystemSe...
Script     0.1.0      AzureRM.MarketplaceOrdering         {Get-AzureRmMarketplaceTerms, Set-AzureRmMarketplaceTerms}                                                                                       
Script     0.7.7      AzureRM.Media                       {Sync-AzureRmMediaServiceStorageKeys, Set-AzureRmMediaServiceKey, Get-AzureRmMediaServiceKeys, Get-AzureRmMediaServiceNameAvailability...}       
Script     4.4.1      AzureRM.Network                     {Add-AzureRmApplicationGatewayAuthenticationCertificate, Get-AzureRmApplicationGatewayAuthenticationCertificate, New-AzureRmApplicationGateway...
Manifest   0.9.1      AzureRM.Network.Netcore             {Add-AzureRmApplicationGatewayAuthenticationCertificate, Get-AzureRmApplicationGatewayAuthenticationCertificate, New-AzureRmApplicationGateway...
Script     3.4.1      AzureRM.NotificationHubs            {Get-AzureRmNotificationHub, Get-AzureRmNotificationHubAuthorizationRules, Get-AzureRmNotificationHubListKeys, Get-AzureRmNotificationHubPNSCr...
Script     3.4.1      AzureRM.OperationalInsights         {New-AzureRmOperationalInsightsAzureActivityLogDataSource, New-AzureRmOperationalInsightsCustomLogDataSource, Disable-AzureRmOperationalInsigh...
Script     3.4.1      AzureRM.PowerBIEmbedded             {Remove-AzureRmPowerBIWorkspaceCollection, Get-AzureRmPowerBIWorkspaceCollection, Get-AzureRmPowerBIWorkspaceCollectionAccessKeys, Get-AzureRm...
Script     3.4.1      AzureRM.profile                     {Disable-AzureRmDataCollection, Disable-AzureRmContextAutosave, Enable-AzureRmDataCollection, Enable-AzureRmContextAutosave...}                  
Manifest   0.9.1      AzureRM.Profile.Netcore             {Disable-AzureRmDataCollection, Enable-AzureRmDataCollection, Remove-AzureRmEnvironment, Get-AzureRmEnvironment...}                              
Script     3.4.1      AzureRM.RecoveryServices            {Get-AzureRmRecoveryServicesBackupProperty, Get-AzureRmRecoveryServicesVault, Get-AzureRmRecoveryServicesVaultSettingsFile, New-AzureRmRecover...
Script     3.4.1      AzureRM.RecoveryServices.Backup     {Backup-AzureRmRecoveryServicesBackupItem, Get-AzureRmRecoveryServicesBackupManagementServer, Get-AzureRmRecoveryServicesBackupContainer, Unre...
Script     3.4.1      AzureRM.RedisCache                  {Remove-AzureRmRedisCachePatchSchedule, New-AzureRmRedisCacheScheduleEntry, Get-AzureRmRedisCachePatchSchedule, New-AzureRmRedisCachePatchSche...
Script     0.2.7      AzureRM.Relay                       {New-AzureRmRelayNamespace, Get-AzureRmRelayNamespace, Set-AzureRmRelayNamespace, Remove-AzureRmRelayNamespace...}                               
Script     4.4.1      AzureRM.Resources                   {Get-AzureRmProviderOperation, Remove-AzureRmRoleAssignment, Get-AzureRmRoleAssignment, New-AzureRmRoleAssignment...}                            
Manifest   0.9.1      AzureRM.Resources.Netcore           {Get-AzureRmProviderOperation, Remove-AzureRmRoleAssignment, Get-AzureRmRoleAssignment, New-AzureRmRoleAssignment...}                            
Script     0.15.7     AzureRM.Scheduler                   {Disable-AzureRmSchedulerJobCollection, Enable-AzureRmSchedulerJobCollection, Get-AzureRmSchedulerJobCollection, Get-AzureRmSchedulerJob...}     
Script     3.4.1      AzureRM.ServerManagement            {Invoke-AzureRmServerManagementPowerShellCommand, Get-AzureRmServerManagementSession, New-AzureRmServerManagementSession, Remove-AzureRmServer...
Script     0.4.7      AzureRM.ServiceBus                  {New-AzureRmServiceBusNamespace, Get-AzureRmServiceBusNamespace, Set-AzureRmServiceBusNamespace, Remove-AzureRmServiceBusNamespace...}           
Script     0.2.7      AzureRM.ServiceFabric               {Add-AzureRmServiceFabricApplicationCertificate, Add-AzureRmServiceFabricClientCertificate, Add-AzureRmServiceFabricClusterCertificate, Add-Az...
Script     4.4.1      AzureRM.SiteRecovery                {Get-AzureRmSiteRecoveryFabric, New-AzureRmSiteRecoveryFabric, Remove-AzureRmSiteRecoveryFabric, Stop-AzureRmSiteRecoveryJob...}                 
Script     3.4.1      AzureRM.Sql                         {Get-AzureRmSqlDatabaseTransparentDataEncryption, Get-AzureRmSqlDatabaseTransparentDataEncryptionActivity, Set-AzureRmSqlDatabaseTransparentDa...
Script     3.4.1      AzureRM.Storage                     {Get-AzureRmStorageAccount, Get-AzureRmStorageAccountKey, New-AzureRmStorageAccount, New-AzureRmStorageAccountKey...}                            
Manifest   0.9.1      AzureRM.Storage.Netcore             {Get-AzureRmStorageAccount, Get-AzureRmStorageAccountKey, New-AzureRmStorageAccount, New-AzureRmStorageAccountKey...}                            
Script     3.4.1      AzureRM.StreamAnalytics             {Get-AzureRmStreamAnalyticsFunction, Get-AzureRmStreamAnalyticsDefaultFunctionDefinition, New-AzureRmStreamAnalyticsFunction, Remove-AzureRmSt...
Script     3.4.1      AzureRM.Tags                        {Remove-AzureRmTag, Get-AzureRmTag, New-AzureRmTag}                                                                                              
Manifest   0.9.1      AzureRM.Tags.Netcore                {Remove-AzureRmTag, Get-AzureRmTag, New-AzureRmTag}                                                                                              
Script     3.4.1      AzureRM.TrafficManager              {Disable-AzureRmTrafficManagerEndpoint, Enable-AzureRmTrafficManagerEndpoint, Set-AzureRmTrafficManagerEndpoint, Get-AzureRmTrafficManagerEndp...
Script     3.4.1      AzureRM.UsageAggregates             Get-UsageAggregates                                                                                                                              
Script     3.4.1      AzureRM.Websites                    {Get-AzureRmAppServicePlan, Set-AzureRmAppServicePlan, New-AzureRmAppServicePlan, Remove-AzureRmAppServicePlan...}                               
Manifest   0.9.1      AzureRM.Websites.Netcore            {Get-AzureRmAppServicePlan, Set-AzureRmAppServicePlan, New-AzureRmAppServicePlan, Remove-AzureRmAppServicePlan...}   

Expected behavior

I expect to be able to uninstall the AzureRM module

Environment data

> $PSVersionTable
Name                           Value                                                                                                                                                                       
----                           -----                                                                                                                                                                       
PSVersion                      6.0.0-beta.9                                                                                                                                                                
PSEdition                      Core                                                                                                                                                                        
GitCommitId                    v6.0.0-beta.9                                                                                                                                                               
OS                             Darwin 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64                                                              
Platform                       Unix                                                                                                                                                                        
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                     
PSRemotingProtocolVersion      2.3                                                                                                                                                                         
SerializationVersion           1.1.0.1                                                                                                                                                                     
WSManStackVersion              3.0     
Area-PowerShellGet Resolution-External

Most helpful comment

Just in case this helps anyone, I was having the same issue and the command:
Get-Module -ListAvailable | Where-Object {$_.Name -like 'AzureRM*'} | Uninstall-Module
successfully removed the expected modules (make sure to run powershell as sudo if that's how you installed the modules to begin with)

All 3 comments

@Michal-Ziemba can you open this issue here? https://github.com/powershell/powershellget/issues

Just in case this helps anyone, I was having the same issue and the command:
Get-Module -ListAvailable | Where-Object {$_.Name -like 'AzureRM*'} | Uninstall-Module
successfully removed the expected modules (make sure to run powershell as sudo if that's how you installed the modules to begin with)

@mszu Thanks!
@SteveL-MSFT Done

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alx9r picture alx9r  ·  3Comments

JohnLBevan picture JohnLBevan  ·  3Comments

MaximoTrinidad picture MaximoTrinidad  ·  3Comments

aragula12 picture aragula12  ·  3Comments

SteveL-MSFT picture SteveL-MSFT  ·  3Comments