PowerShell: Get Azure VMs with no base marketplace image.

Whilst most Virtual Machines in Azure are built from Marketplace images, this isn’t always the case. This PowerShell snippet will find VMs in your subscription which are not built on Marketplace images.

A requirement came up to identify which Azure Virtual Machines had been through a lift-and-shift migration rather than being deployed natively. In the environment in question, checking for an absence of base image was sufficient to produce this list. Here is the PowerShell snippet: