如何找到用于使用 PowerShell 创建 Azure VM 的 VM 映像的名称?
How can I find the name of the VM image used to create an Azure VM using PowerShell?
如果我使用 Get-AzureVM (PowerShell cmdlet) 获取 运行 VM,那么我返回的字段是
DeploymentName
Name
Label
VM
InstanceStatus
IpAddress
InstanceStateDetails
PowerState
InstanceErrorCode
InstanceFaultDomain
InstanceName
InstanceUpgradeDomain
InstanceSize
HostName
AvailabilitySetName
DNSName
Status
GuestAgentStatus
ResourceExtensionStatusList
PublicIPAddress
PublicIPName
PublicIPDomainNameLabel
PublicIPFqdns
NetworkInterfaces
VirtualNetworkName
ServiceName
OperationDescription
OperationId
OperationStatus
但是我看不到用于创建 VM 的映像的名称。我可以使用 Azure 门户(在“设置”>“属性”>“源图像名称”下)查看此信息。如何使用 PowerShell 获取源图像名称?
您从操作系统磁盘的属性中获取源映像 ID。
试试这个:
$vm = Get-AzureVM -ServiceName serviceName -Name vmName
$vm.VM.OSVirtualHardDisk
然后你应该得到这个例如:
HostCaching : ReadWrite
DiskLabel :
DiskName : multinicdemo-host1-0-201504131546160112
MediaLink : https://multinicdemo.blob.core.windows.net/vhds/multinicdemo-host1-2015-4-13-17-46-7-664-0.vhd
SourceImageName : a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-201503.01-en.us-127GB.vhd
OS : Windows
IOType : Standard
ResizedSizeInGB :
ExtensionData :
或者在一行中:
(Get-AzureVM -ServiceName serviceName -Name vmName).VM.OSVirtualHardDisk.SourceImageName
如果您想在不使用 cmd/Powershell 的情况下查看源图像,请按照以下步骤操作:
如何查找 运行 VM 映像版本。
> Go to azure portal
> Select the running/stopped VM whose image you want to identify
> Go to export template option
> On the right side of the screen, you will see the template window will open in JSON format.
> Ctrl+F (search) > imageReference > you will get your image version in the template.
在新的“Az”Powershell 模块中,您必须检查源图像,如下所示:
> $vm = (Get-AzVM -Name <VM_NAME>)
> $vm.StorageProfile.ImageReference
你应该得到这样的东西:
Publisher :
Offer :
Sku :
Version :
ExactVersion : 1.0.0
Id : <RESOURCE_ID_FOR_YOUR_IMAGE>
如果我使用 Get-AzureVM (PowerShell cmdlet) 获取 运行 VM,那么我返回的字段是
DeploymentName
Name
Label
VM
InstanceStatus
IpAddress
InstanceStateDetails
PowerState
InstanceErrorCode
InstanceFaultDomain
InstanceName
InstanceUpgradeDomain
InstanceSize
HostName
AvailabilitySetName
DNSName
Status
GuestAgentStatus
ResourceExtensionStatusList
PublicIPAddress
PublicIPName
PublicIPDomainNameLabel
PublicIPFqdns
NetworkInterfaces
VirtualNetworkName
ServiceName
OperationDescription
OperationId
OperationStatus
但是我看不到用于创建 VM 的映像的名称。我可以使用 Azure 门户(在“设置”>“属性”>“源图像名称”下)查看此信息。如何使用 PowerShell 获取源图像名称?
您从操作系统磁盘的属性中获取源映像 ID。
试试这个:
$vm = Get-AzureVM -ServiceName serviceName -Name vmName
$vm.VM.OSVirtualHardDisk
然后你应该得到这个例如:
HostCaching : ReadWrite
DiskLabel :
DiskName : multinicdemo-host1-0-201504131546160112
MediaLink : https://multinicdemo.blob.core.windows.net/vhds/multinicdemo-host1-2015-4-13-17-46-7-664-0.vhd
SourceImageName : a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-201503.01-en.us-127GB.vhd
OS : Windows
IOType : Standard
ResizedSizeInGB :
ExtensionData :
或者在一行中:
(Get-AzureVM -ServiceName serviceName -Name vmName).VM.OSVirtualHardDisk.SourceImageName
如果您想在不使用 cmd/Powershell 的情况下查看源图像,请按照以下步骤操作: 如何查找 运行 VM 映像版本。
> Go to azure portal
> Select the running/stopped VM whose image you want to identify
> Go to export template option
> On the right side of the screen, you will see the template window will open in JSON format.
> Ctrl+F (search) > imageReference > you will get your image version in the template.
在新的“Az”Powershell 模块中,您必须检查源图像,如下所示:
> $vm = (Get-AzVM -Name <VM_NAME>)
> $vm.StorageProfile.ImageReference
你应该得到这样的东西:
Publisher :
Offer :
Sku :
Version :
ExactVersion : 1.0.0
Id : <RESOURCE_ID_FOR_YOUR_IMAGE>