Azure ARM 模式虚拟机:
1.登陆Azure账号
Add-AzureRmAccount -EnvironmentName AzurechinaCloud
2.选择指定订阅
Select-AzureRmSubscription -Subscription ******
3.获取指定虚拟机信息
$vm = Get-AzureRmVM -ResourceGroupName ****** -Name ******
4.获取虚拟机操作系统型号及具体版本
Windows VM: PS C:\Users\he.liming> $vm = Get-AzureRmVM -ResourceGroupName hlmrgn -Name hlmwin12test PS C:\Users\he.liming> $vm.StorageProfile.OsDisk.OsType Windows PS C:\Users\he.liming> $vm.StorageProfile.ImageReference Publisher : MicrosoftWindowsServer Offer : WindowsServer Sku : 2012-R2-Datacenter Version : latest Id : Linux VM: PS C:\Users\he.liming> $vm = Get-AzureRmVM -ResourceGroupName hlmrgn -Name hlmcent74n PS C:\Users\he.liming> $vm.StorageProfile.OsDisk.OsType Linux PS C:\Users\he.liming> $vm.StorageProfile.ImageReference Publisher : OpenLogic Offer : CentOS Sku : 7.4 Version : latest Id :
5.上述4获取的虚拟机版本信息仅限于通过Azure镜像库创建的虚拟机,如果自定义上传VHD创建的虚拟机或使用捕获的Image创建的虚拟机无法获取到具体版本信息,只能获取到版本型号
PS C:\Users\he.liming> $vm = Get-AzureRmVM -ResourceGroupName hlmrgn -Name hlmtestn PS C:\Users\he.liming> $vm.StorageProfile.OsDisk.OsType Linux PS C:\Users\he.liming> $vm.StorageProfile.ImageReference Publisher : Offer : Sku : Version : Id : /subscriptions/6c87a588-88df-48ee-9e52-d04b06a8601f/resourceGroups/hlmrgn/providers/Microsoft.Compute/images/capture-hlmma69n2
Azure ASM 模式虚拟机:
1.登陆Azure账号
Add-AzureAccount -Environment AzureChinaCloud
2.获取当前操作的订阅信息
Get-AzureSubscription -Default
3.获取指定虚拟机信息
$vm = Get-AzureVM -ServiceName ****** -Name ******
4.获取虚拟机操作系统型号及具体版本
PS C:\Users\he.liming> $vm = Get-AzureVM -ServiceName hlmtest1 -Name hlmsct2 PS C:\Users\he.liming> $vm.VM.OSVirtualHardDisk.os Linux PS C:\Users\he.liming> $vm.VM.OSVirtualHardDisk.SourceImageName f1179221e23b4dbb89e39d70e5bc9e72__OpenLogic-CentOS-73-20170925
I hear and I forget. I see and I remeber. I do and I understand!