术语“Select-AzureSubscription”未被识别为 cmdlet、函数的名称

问题描述

我运行以下命令:-

PS C:\WINDOWS\system32> Connect-AzureRmAccount
WARNING: Because the Az modules have all the capabilities of AzureRM modules and more,we will retire the AzureRM
modules on 29 February 2024. Learn more about the migration to Az: http://aka.ms/azpsmigrate.

Account                                 SubscriptionName TenantId                             Environment
-------                                 ---------------- --------                             -----------
**.***@****.onmicrosoft.com                  e***-b4fb-0*** AzureCloud


PS C:\WINDOWS\system32> az login --tenant "c*f"
You have logged in. Now let us find all the subscriptions to which you have access...
[
  {
    "cloudName": "AzureCloud","id": "b**4","isDefault": true,"name": "Microsoft Azure","state": "Enabled","tenantId": "c**f","user": {
      "name": "***@***.onmicrosoft.com","type": "user"
    }
  }
]
PS C:\WINDOWS\system32> Select-AzureSubscription -Current -SubscriptionId "b**4"
Select-AzureSubscription : The term 'Select-AzureSubscription' 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
+ Select-AzureSubscription -Current -SubscriptionId "b1597bc1-913e-4da7 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Select-AzureSubscription:String) [],CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

但我收到上述错误有什么建议吗? 谢谢

编辑

我运行这个命令:-

  az login --tenant "c*f"

我得到了这个结果

You have logged in. Now let us find all the subscriptions to which you have access...
[
  {
    "cloudName": "AzureCloud","type": "user"
    }
  }
]

但是当我运行这个命令时:-

Select-AzureRmSubscription -Subscription "b**4"  -Tenant "c**f"

我得到了这个结果

WARNING: Because the Az modules have all the capabilities of AzureRM modules and more,we will retire the AzureRM
modules on 29 February 2024. Learn more about the migration to Az: http://aka.ms/azpsmigrate.
Select-AzureRmSubscription : Please provide a valid tenant or a valid subscription.
At line:1 char:1
+ Select-AzureRmSubscription -Subscription "b ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Set-AzureRmContext],ArgumentException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.SetAzureRMContextCommand

EDIT-2

我试过这个命令:-

PS C:\WINDOWS\system32> Get-AzureRmSubscription -Subscription "b**4"  -Tenant "c**f"

但我收到此错误:-

Get-AzureRmSubscription : Parameter cannot be processed because the parameter name 'Subscription' is ambiguous.
Possible matches include: -SubscriptionId -SubscriptionName.
At line:1 char:25
+ Get-AzureRmSubscription -Subscription "b1597bc1-913e-4da7-a020-be3029 ...
+                         ~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-AzureRmSubscription],ParameterBindingException
    + FullyQualifiedErrorId : AmbiguousParameter,Microsoft.Azure.Commands.Profile.GetAzureRMSubscriptionCommand

所以我运行这个命令:-

PS C:\WINDOWS\system32> Get-AzureRmSubscription -SubscriptionId "b**4"  -Tenant "c**f"

但是得到这个错误:-

WARNING: Because the Az modules have all the capabilities of AzureRM modules and more,we will retire the AzureRM
modules on 29 February 2024. Learn more about the migration to Az: http://aka.ms/azpsmigrate.
WARNING: Unable to acquire token for tenant 'cfcab407-f59a-4db4-aec9-d5d3676d708f'
Get-AzureRmSubscription : Subscription b1597bc1-913e-4da7-a020-be30291a6494 was not found in tenant
cfcab407-f59a-4db4-aec9-d5d3676d708f. Please verify that the subscription exists in this tenant.
At line:1 char:1
+ Get-AzureRmSubscription -SubscriptionId "b1597bc1-913e-4da7-a020-be30 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Get-AzureRmSubscription],PSArgumentException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.GetAzureRMSubscriptionCommand

解决方法

你可以试试下面的命令行:

Select-AzureRmSubscription -Subscription <SUBSCRIPTION> -Tenant <TENANTID>
,

使用下面的命令,因为 -current 不是查询中的正确参数

enter image description here

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...