Azure Powershell对ASM资源的基本操作

本文主要介绍Windows Azure Powershell对ASM资源的基本操作

1.登陆ASM模式,命令:Add-AzureAccount -Environment AzureChinaCloud

2.获取订阅信息,命令:Get-AzureSubscription

3.设置指定的操作订阅及指定的存储账号,命令:

    Set-AzureSubscription -SubscriptionId “******” -CurrentStorageAccountName “******”

    Select-AzureSubscription -SubscriptionId "******" -Current

4.查看默认的操作订阅或当前的操作订阅,命令:

    Get-AzureSubscription -Current
    Get-AzureSubscription -Default

5.获取虚拟机的信息,命令:Get-AzureVM

6.获取存储账号的信息,命令:Get-AzureStorageAccount

7.获取自动化服务的信息,命令:Get-AzureAutomationAccount

8.查询一个陌生的操作命令,示例:get-command get-azurev*

9.获取指定命令的操作手册,示例:Get-Help Get-AzureAutomationAccount -Full

备注:

a.有时安装完Windows Azure Powershell会出现一种比较奇怪的现象,确认已经成功安装了,命令也可以使用Tab键自动补齐,但没有相应的显示参数信息,例如:

PS C:Usersstone> get-help Add-AzureAccount -full

名称
Add-AzureAccount

语法

参数
无


输入
无


输出
System.Object

别名
无


备注
无

b.出现上述情况后,需要将Azure模块导入当前操作的Powershell,命令:Import-Module -Name Azure;并可以查看当前Powershell所拥有的模块,命令:Get-Module

PS C:Usersstone> Import-Module -Name Azure
PS C:Usersstone> Get-Module

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   4.3.1      Azure                               {Add-AzureAccount, Add-AzureApplicationGatewaySslCertificate, Add-AzureCertificate, Add-AzureDataDisk...}
Manifest   3.3.1      Azure.Storage                       {Get-AzureStorageBlob, Get-AzureStorageBlobContent, Get-AzureStorageBlobCopyState, Get-AzureStorageContainer...}
Manifest   3.3.1      AzureRM.Profile                     {Add-AzureRmAccount, Add-AzureRmEnvironment, Disable-AzureRmDataCollection, Enable-AzureRmDataCollection...}
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}

c.再次运行预操作的命令,可以成功获取到其参数

PS C:Usersstone> Add-AzureAccount -Environment AzureChinaCloud

Id                                                                                                                           Type
--                                                                                                                           ----
WATSTest03@MicrosoftInternal.partner.onmschina.cn                                                                            User


PS C:Usersstone> get-help Add-AzureAccount -full

名称
    Add-AzureAccount

摘要
    Adds the Azure account to Windows PowerShell

语法
    Add-AzureAccount [-Environment <String>] [-Credential <PSCredential>] [-Profile <AzureProfile>] [<CommonParameters>]

    Add-AzureAccount [-Environment <String>] [-Credential <PSCredential>] -ServicePrincipal [<SwitchParameter>] -Tenant <String> [-Profile <AzureProfile>] [<CommonParameters>]
I hear and I forget. I see and I remeber. I do and I understand!
原文地址:https://www.cnblogs.com/stonehe/p/7514468.html