#登录
$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. Activity参数传递

    简单数据传递 putExtra() 传递 findViewById(R.id.button).setOnClickListener(new View.OnClickListener() { @Over ...

  2. 必须知道的八大种排序算法【java实现】

    一.冒泡排序 冒泡排序是一种简单的排序算法.它重复地走访过要排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交换过来.走访数列的工作是重复地进行直到没有再需要交换,也就是说该数列已经排序完成. ...

  3. Deques and Randomized Queues

    1. 题目重述 完成三个程序,分别是双向队列,随机队列,和随机队列读取文本并输出k个数. 2. 分析 2.1 双向队列 题目的性能要求是,操作时间O(1),内存占用最大48n+192byte. 当使用 ...

  4. sql语句之正则表达式

    select * from employee where name regexp '^jin' select * from employee where name regexp '^jin.*(g|n ...

  5. 【Data Structure & Algorithm】 查找最小的k个元素

    查找最小的k个元素 题目:输入n个整数,输出其中最小的k个. 例如输入1, 2, 3, 4, 5, 6, 7和8这八个数字,则最小的4个数字为1, 2, 3和4. 分析:这道题最简单的思路是把输入的n ...

  6. XML DOM 笔记

    一.概念理解: 关于Element跟Node的区别,cilldren跟childNodes的区别很多朋友弄不清楚,本文试图让大家明白这几个概念之间的区别. Node(节点)是DOM层次结构中的任何类型 ...

  7. Laravel框架之Response操作

    public function response(){ //响应json /*$data = [ 'errCode'=>0, 'errMsg' =>'success', 'data' =& ...

  8. 201621123016 《Java程序设计》第八周学习总结

    1. 本周学习总结 2. 书面作业 1. ArrayList代码分析 1.1 解释ArrayList的contains源代码 ArrayList在调用contains方法时会调用indexOf方法得到 ...

  9. art-template在项目中的应用

    art-template 是一个简约.超快的模板引擎.它采用作用域预声明的技术来优化模板渲染速度,从而获得接近 JavaScript 极限的运行性能,并且同时支持 NodeJS 和浏览器. 下面介绍在 ...

  10. 怎么在const成员函数里面调用非const成员函数?

    举个例子: 定义了一个类的const实例,怎么让他也能调用非能调用非const成员函数class foo{public:void test1() {cout << "I am n ...