If I use Get-AzureVM (PowerShell cmdlet) to fetch a running VM then the fields I get back are
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
However I cannot see the name of the image used to create the VM. I can see this information using the Azure portal (under Settings > Properties > SOURCE IMAGE NAME). How can I get the source image name using PowerShell?
You get the source image ID from the operating system disk's properties.
Try this:
$vm = Get-AzureVM -ServiceName serviceName -Name vmName
$vm.VM.OSVirtualHardDisk
Then you should get this for example:
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 :
Or in one line:
(Get-AzureVM -ServiceName serviceName -Name vmName).VM.OSVirtualHardDisk.SourceImageName