Login-AzureRmAccount:术语 'Login-AzureRmAccount' 未被识别为 cmdlet、函数、脚本的名称

Login-AzureRmAccount : The term 'Login-AzureRmAccount' is not recognized as the name of a cmdlet, function, script

我遇到了 Azure PS 模块的问题。我已经通过 PS 画廊安装了以下内容:

Install-Module AzureRM
Install-Module Azure

(并重新启动)

但是,当我 运行 Login-AzureRmAccount 我得到以下错误:

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

我似乎安装了所有 Azure 模块。 IE。如果我 运行 Get-Module -List 我得到关注。

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...
...

希望有人能提供帮助? 运行 Windows Server 2012 R2 with Powershell 4

此致

您可以使用 link 的最新 Azure Power Shell 版本。

注意:请安装3.7.0版本。

您需要更新到新版本的 Azure PowerShell。

  • 使用命令:

安装模块 AzureRM -AllowClobber

参考文章:https://docs.microsoft.com/en-us/powershell/azure/install-azurerm-ps

对我来说,Install-Module没有被识别,我已经安装了Azure 3.7,答案是安装Azure CLI 2.0 for Windows

当 运行将 Powershell 脚本作为计划任务(使用为 运行ning 计划任务保留的用户配置文件)时,我遇到了这个问题,但当 运行ning 从Powershell 以管理员身份交互提示。 (我使用的是 Powershell 5.1 版。)

Get-Module -List 似乎告诉我所需的 AzureRm 模块已经为所有用户安装(在 C:\Program Files\WindowsPowerShell\Modules 下)。尽管如此,它们似乎并没有为任务用户安装。

我在我的计划任务中放置了一个设置例程,以便 运行 在我的任务上下文中执行以下命令:

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

(似乎已经安装了 4.0.1 版)。

我还必须使用 Install-Module PowershellGet -Force 来让 Install-Module 的 'Scope' 参数被接受。不清楚这三个命令中的哪一个最终起到了作用。

我在 Powershell 中安装 Az 模块后遇到了类似的问题。 在特定会话中,PowerShell 可以 运行 Rm 命令或 Az 命令。

至运行 RM命令:

  • 打开一个新的 Powershell window。
  • 使用命令重新安装 AzureRM 模块:

Install-Module "AzureRM"

  • 运行 rm 命令如常。

希望这能解决您的问题。