Skip to content

Instantly share code, notes, and snippets.

@blakedrumm
Created February 28, 2024 00:26
Show Gist options
  • Save blakedrumm/5f003706002fddbd5af87b6ccdf67915 to your computer and use it in GitHub Desktop.
Save blakedrumm/5f003706002fddbd5af87b6ccdf67915 to your computer and use it in GitHub Desktop.
An Azure Resource Graph query to efficiently map and manage microsoft.hybridcompute/machines with detailed insights on OS versions, agent details, and provisioning statuses for improved infrastructure oversight.
/*
Author: Blake Drumm (blakedrumm@microsoft.com)
Date Created: February 27th, 2024
Description:
Azure Resource Graph query for enhanced inventory management of microsoft.hybridcompute/machines,
detailing essential attributes such as display names, operating system versions with friendly names for Windows 11,
Windows 10, and various Windows Server releases, agent version, automatic upgrade capability, provisioning state,
and ESU license status. By using regular expressions for accurate OS version categorization, it offers administrators
and support teams a powerful tool for comprehensive oversight and management of hybrid computing environments,
facilitating effective upgrade planning, compliance monitoring, and support tasks.
*/
Resources
| where type == 'microsoft.hybridcompute/machines'
| project displayName = tostring(properties.displayName),
OsVersion = case(
// Windows 11 versions
properties.osVersion matches regex "^10.0.22631", "Windows 11, Version 21H2",
properties.osVersion matches regex "^10.0.22621", "Windows 11, Version 22H2",
properties.osVersion matches regex "^10.0.22000", "Windows 11",
// Windows 10 versions
properties.osVersion matches regex "^10.0.19041", "Windows 10, Version 2004",
properties.osVersion matches regex "^10.0.18362", "Windows 10, Version 1903",
// Windows Server versions
properties.osVersion matches regex "^10.0.20348", "Windows Server 2022",
properties.osVersion matches regex "^10.0.17763", "Windows Server 2019",
properties.osVersion matches regex "^10.0.14393", "Windows Server 2016",
properties.osVersion matches regex "^6.3.9600", "Windows Server 2012 R2",
properties.osVersion matches regex "^6.2.9200", "Windows Server 2012",
properties.osVersion matches regex "^6.1.*", "Windows Server 2008/Windows 7",
// Future versions placeholder
properties.osVersion matches regex "^10.0.*", "Future Windows Version",
// Default case
properties.osVersion
),
agentVersion = tostring(properties.agentVersion),
enableAutomaticUpgrade = tostring(properties.agentUpgrade.enableAutomaticUpgrade),
provisioningState = properties['provisioningState'],
esuLicense = properties['licenseProfile']['esuProfile']['licenseAssignmentState']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment