#登录
$username="{登录名}"  #定义一个用户账号的变量,可以输入需要登录的订阅账号名称
$password=ConvertTo-SecureString -String "{密码}" -AsPlainText -Force #对密码进行转换字符加密
$cred= New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username,$password #定义登录的密钥
Login-AzureRmAccount -EnvironmentName AzureChinaCloud -Credential $cred #登录

# 选择订阅
Get-AzureRmSubscription | select Name, SubscriptionId
$subscriptionId=Read-Host "请选择上面列出的订阅ID:"#多种订阅条件下,因订阅不同,所以要选择一个默认订阅
Write-Host "Selecting subscription '$subscriptionId'";
Select-AzureRmSubscription -SubscriptionID $subscriptionId;

###############获取订阅下可用的image,并打印image信息
$images = New-Object System.Collections.ArrayList;
$location = "China North";
$publishers = Get-AzureRmVMImagePublisher -Location $location;

foreach($publisher in $publishers)
 {
    $offers = Get-AzureRmVMImageOffer -Location $location -PublisherName $publisher.PublisherName;
    foreach($offer in $offers)
    {
        $skus = Get-AzureRmVMImageSku -Location $location -PublisherName $publisher.PublisherName -Offer $offer.Offer;
        foreach($sku in $skus)
        {
            $image = Get-AzureRmVMImage -Location $location -PublisherName $publisher.PublisherName -Offer $offer.Offer -Skus $sku.Skus;
            Write-Output $image  #打印
            $images.Add($image);
        }
    }
    }

foreach($image in $images)
{
    $len = $image.Count;
    if ($len -gt 0)
    {
        $image[$len-1] | select PublisherName,Offer,Skus,Version;
    }
}

在ARM模板中引用镜像时,一般Version参数为 latest,其他几个参数需要指定

 "imageReference": {
            "publisher": "[variables('imagePublisher')]",
            "offer": "[variables('imageOffer')]",
            "sku": "[variables('imageSku')]",
            "version": "latest"
          },

  

Azure Powershell 获取可用镜像 PublisherName,Offer,Skus,Version的更多相关文章

  1. azure powershell 获取可用镜像列表

    通过Azure Powershell 指定location和Pbulishername 获取所有可用镜像的 publisherName,Offer,Skus,Version,location信息列表 ...

  2. 通过Azure Powershell获取asm及arm虚拟机的配置信息

    1.asm虚拟机可以使用类似如下Azure Powershell命令获取虚拟机的基本信息,包括发行版本,虚拟机名称及size[备注:虚拟机需要是使用平台image创建的] PS C:\Users\he ...

  3. Azure Powershell获取Azure虚拟机的操作系统型号及具体版本

    Azure ARM 模式虚拟机: 1.登陆Azure账号 Add-AzureRmAccount -EnvironmentName AzurechinaCloud 2.选择指定订阅 Select-Azu ...

  4. Azure powershell 获取 vmSize 可用列表的命令

    1.使用 Add-AzureAccount -Environment azurechinacloud 登录到订阅 2.选择默认的订阅 Select-AzureSubscription -Subscri ...

  5. Azure Powershell获取指定订阅下的虚拟机信息(ARM)

    为方便Azure用户导出已创建虚拟机的相关信息,特编写如下脚本: 详情脚本: # 登陆Azure Account Add-AzureRmAccount -EnvironmentName AzureCh ...

  6. Azure Powershell获取指定订阅下的虚拟机信息(ASM)

    为方便Azure用户导出已创建虚拟机的相关信息,特编写如下脚本: 详情脚本: # 登陆Azure Account Add-AzureAccount -Environment AzureChinaClo ...

  7. Microsoft Azure Powershell 获取Azure-Location

    首先要切换至AzureResourceManager模式下 http://www.cnblogs.com/SignalTips/p/4110790.html 国际版Get-AzureLocation ...

  8. 使用PowerShell 获取azure image publisher offer sku 信息

    使用azure powershell 获取指定区域的可用镜像 publisher offer sku信息 param ( [parameter(Mandatory = $false)] $Locati ...

  9. Azure VMSS ---- PowerShell创建自定义镜像的VMSS集群

    前面一篇文章介绍了如何用PowerShell创建标准镜像的VMSS集群.http://www.cnblogs.com/hengwei/p/7391178.html 本文将介绍,如何用PowerShel ...

随机推荐

  1. AndroidStudio检测不到genymotion虚拟设备

    重启adb 单击  Reset adb

  2. android项目源码

    [置顶] Android精品开源项目整理_V20140221(持续更新中..) 让我们回顾下2013年有哪些精品资源:Android精品开源项目整理_V20131115(持续更新中..) 引言:   ...

  3. 1.SJ-SLAM-14

    1.引言 SLAM:Simultaneous Localization and Mapping 同时定位与地图构建 搭载特定传感器的主体,在没有环境先验信息的情况下,于运动过程中建立环境的模型,同时估 ...

  4. java集合框架之HashCode

    参考http://how2j.cn/k/collection/collection-hashcode/371.html List查找的低效率 假设在List中存放着无重复名称,没有顺序的2000000 ...

  5. Fitnesse + Xebium环境搭建

    1.在搭建Fitnesse + Xebium环境之前先将selenium基础环境搭建完成并调试成功 参照:http://www.cnblogs.com/moonpool/p/5480724.html ...

  6. MySQL Bug剖析之Slave节点并行复制死锁

    此文已由作者温正湖授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 有天一早,DBA同学就找上来了,说有个DDB集群下的RDS实例Slave节点(从库)死锁了,请求支援.说实话 ...

  7. Sublime text3 插件ColorPicker(调色板)不能使用快捷键

    我的原因是: convertToUTF8 和 ColorPicker 快捷键冲突,convertoUTF8的默认转换GBK的快捷键 和 ColorPicker打开调色板的快捷键都是ctrl+shift ...

  8. Python-1-基础

    获取用户输入 >>> x = input("x: ") x: 34 >>> y = input("y: ") y: 42 & ...

  9. with rollup

    实验吧的一道ctf题,这两天无聊,做做ctf题.在实验吧被一道也题卡了好久. 页面很简单就是一个登陆页面,按照之前的经验觉得应该是注入吧.再看题猜测应该是绕waf之类的. 查看页面源码找到了提供的源代 ...

  10. ZROI #364. 【2018普转提day18专题】嘤嘤嘤

    ZROI #364. [2018普转提day18专题]嘤嘤嘤 直接贴代码 具体见注释 #include<stdio.h> #include<cstring> #include& ...