Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何找到用于使用PowerShell创建Azure VM的VM映像的名称?_Azure_Azure Vm Role - Fatal编程技术网

如何找到用于使用PowerShell创建Azure VM的VM映像的名称?

如何找到用于使用PowerShell创建Azure VM的VM映像的名称?,azure,azure-vm-role,Azure,Azure Vm Role,如果使用Get-AzureVM(PowerShell cmdlet)获取正在运行的VM,则返回的字段为 DeploymentName Name Label VM InstanceStatus IpAddress InstanceStateDetails PowerState InstanceErrorCode InstanceFaultDomain InstanceName InstanceUpgradeDomain InstanceSize HostName AvailabilitySetNa

如果使用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
$vm=(获取AzVM-Name)
>$vm.StorageProfile.ImageReference
你应该得到这样的东西:

Publisher    :
Offer        :
Sku          :
Version      :
ExactVersion : 1.0.0
Id           : <RESOURCE_ID_FOR_YOUR_IMAGE>
发布者:
报价:
Sku:
版本:
ExactVersion:1.0.0
身份证件:

这个答案是正确的。接受的答案提供的操作系统映像可能与Azure映像不同。我认为最初的问题是寻找这个。