PowerShell – Check VMSS Instance Image/Model Versions

Here is a PowerShell script to check the Image or Model versions of each instance in an Azure Virtual Machine Scale Set (VMSS):

$ResourceGroup = "p-we1dep"
$Vmss = "p-we1dep-windows-vmss"

// Find all the instances in the VMSS
$Instances = Get-AzVmssVM -ResourceGroupName $ResourceGroup -Name $Vmss

Write-Host "Instance image versions of VMMS: $Vmss"

// For each instance in the VMSS
foreach ($Instance in $Instances) {

    // Get the exact version of the instance
    $InstanceInfo = (Get-AzVmssVM -ResourceGroupName $ResourceGroup -Name $Vmss -InstanceId $Instance.instanceId).StorageProfile.ImageReference.ExactVersion
    $Id = $Instance.instanceId

    // Echo the instance ID and Exact Version
    Write-Host "Instance $Id - $InstanceExactVersion"
}

2 thoughts on “PowerShell – Check VMSS Instance Image/Model Versions”

  1. Hi Aidan…Good script. Note this works for the traditional VMSS Uniform orchestration mode. VMSS Flexible Orchestration mode is the more modern version of VMSS that scales up/down with ‘regular’Azure VMs, instead of those more limited scale set instances. So you’d just use regular Get-AzVM instead of Get-AzVmssVm

    1. Interesting. My scenario is a DevOps VMSS which was deployed, following Microsoft guidance as a Uniform set. Get-AzVM returns zero results.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.