1. #登录
  2. $username="{登录名}" #定义一个用户账号的变量,可以输入需要登录的订阅账号名称
  3. $password=ConvertTo-SecureString -String "{密码}" -AsPlainText -Force #对密码进行转换字符加密
  4. $cred= New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username,$password #定义登录的密钥
  5. Login-AzureRmAccount -EnvironmentName AzureChinaCloud -Credential $cred #登录
  6.  
  7. # 选择订阅
  8. Get-AzureRmSubscription | select Name, SubscriptionId
  9. $subscriptionId=Read-Host "请选择上面列出的订阅ID:"#多种订阅条件下,因订阅不同,所以要选择一个默认订阅
  10. Write-Host "Selecting subscription '$subscriptionId'";
  11. Select-AzureRmSubscription -SubscriptionID $subscriptionId;
  12.  
  13. ###############获取订阅下可用的image,并打印image信息
  14. $images = New-Object System.Collections.ArrayList;
  15. $location = "China North";
  16. $publishers = Get-AzureRmVMImagePublisher -Location $location;
  17.  
  18. foreach($publisher in $publishers)
  19. {
  20. $offers = Get-AzureRmVMImageOffer -Location $location -PublisherName $publisher.PublisherName;
  21. foreach($offer in $offers)
  22. {
  23. $skus = Get-AzureRmVMImageSku -Location $location -PublisherName $publisher.PublisherName -Offer $offer.Offer;
  24. foreach($sku in $skus)
  25. {
  26. $image = Get-AzureRmVMImage -Location $location -PublisherName $publisher.PublisherName -Offer $offer.Offer -Skus $sku.Skus;
  27. Write-Output $image #打印
  28. $images.Add($image);
  29. }
  30. }
  31. }
  32.  
  33. foreach($image in $images)
  34. {
  35. $len = $image.Count;
  36. if ($len -gt 0)
  37. {
  38. $image[$len-1] | select PublisherName,Offer,Skus,Version;
  39. }
  40. }

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

  1. "imageReference": {
  2. "publisher": "[variables('imagePublisher')]",
  3. "offer": "[variables('imageOffer')]",
  4. "sku": "[variables('imageSku')]",
  5. "version": "latest"
  6. },

  

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. bootStrap效果图

    http://www.ziqiangxuetang.com/bootstrap/bootstrap-tutorial.html

  2. Storm 1.0 新特性

    Storm 1.0.0版本增加了很多新的特性,可用性以及性能也得到了很大的改善,该版本是Storm发展历程上一个里程碑式的版本,主要特点如下. 性能提升 Storm 1.0.0版本最大的亮点就是性能提 ...

  3. 配置哨兵监控Redis运行情况

    Redis的主从架构,如果master发现故障了,还得手动将slave切换成master继续服务,手动的方式容易造成失误,导致数据丢失,那Redis有没有一种机制可以在master和slave进行监控 ...

  4. linux drwxr-xr-x 什么意思

    第一位表示文件类型. d:是目录文件, l:是链接文件, -:是普通文件, p:是管道 第2-4位表示这个文件的属主拥有的权限,r是读,w是写,x是执行.(其中r是4,w是2,x是1) 第5-7位表示 ...

  5. 第三篇:SpringBoot用JdbcTemplates访问Mysql

    本文介绍springboot通过jdbc访问关系型mysql,通过spring的JdbcTemplate去访问. 准备工作 jdk 1.8 maven 3.0 idea mysql 初始化mysql: ...

  6. STL——pair

    功能:pair将一对值组合成一个值,这一对值可以具有不同的数据类型(T1和T2),两个值可以分别用pair的两个公有函数first和second访问. #include <bits/stdc++ ...

  7. 算法学习--Day6

    题目描述 实现一个加法器,使其能够输出a+b的值. 输入描述: 输入包括两个数a和b,其中a和b的位数不超过1000位. 输出描述: 可能有多组测试数据,对于每组数据, 输出a+b的值. 示例1 输入 ...

  8. HDU5112【水】

    #include <bits/stdc++.h> using namespace std; typedef long long LL; const int N=1e4+10; struct ...

  9. 洛谷P1919 【模板】A*B Problem升级版(FFT)

    传送门 话说FFT该不会真的只能用来做这种板子吧…… 我们把两个数字的每一位都看作多项式的系数 然后这就是一个多项式乘法 上FFT就好了 然后去掉前导零 (然而连FFT的板子都背不来orz,而且空间又 ...

  10. Node.js 内置模块fs(文件系统)

    fs模块的三个常用方法 1.fs.readFile() -- 读文件 2.fs.writeFile() -- 写文件 3.fa.stat() -- 查看文件信息 fs模块不同于其它模块的地方是它有异步 ...