Query Details

Azure Resource Graph V Ms Hybrid Compute

Query

resources
| where (type has "compute/virtualmachines" or type has "hybridcompute/machines") and not(type has "extensions")
| project
    id,
    subscriptionId,
    resourceGroup,
    machinename = name,
    type,
    provisioningState = tostring(properties["provisioningState"]),
    status = tostring(properties["status"]),
    osType = tostring(properties["osType"]),
    osName = tostring(properties["osName"]),
    provider = tostring(properties["cloudMetadata"]["provider"]),
    LicenseType = tostring(properties["licenseType"]),
    ExtComputerName = tostring(properties["extended"]["instanceView"]["computerName"]),
    ExtOsName = tostring(properties["extended"]["instanceView"]["osName"]),
    DiskOsType = tostring(properties["storageProfile"]["osDisk"]["osType"]),
    DiskOption = tostring(properties["storageProfile"]["osDisk"]["createOption"]),
    DiskImagePublisher = tostring(properties["storageProfile"]["imageReference"]["publisher"]),
    DiskImageOffer = tostring(properties["storageProfile"]["imageReference"]["offer"]),
    DiskImageSku = tostring(properties["storageProfile"]["imageReference"]["sku"]),
    OsComputerName = tostring(properties["osProfile"]["computerName"])
| order by ['type'] asc

Explanation

This query selects specific information about virtual machines and hybrid machines, excluding extensions. It then projects various properties such as ID, subscription ID, resource group, machine name, status, OS type, provider, and disk information. The results are ordered by type in ascending order.

Details

Jose Sebastián Canós profile picture

Jose Sebastián Canós

Released: March 5, 2024

Tables

resources

Keywords

Devices,Intune,User

Operators

wherehasornotprojectidsubscriptionIdresourceGroupmachinenamenametypeprovisioningStatetostringpropertiesstatusosTypeosNameprovidercloudMetadataLicenseTypeextendedinstanceViewcomputerNameDiskOsTypestorageProfileosDiskcreateOptionimageReferencepublisherofferskuOsComputerNameorder byasc

Actions