Using Get-AzureRmResource to find Azure resources using Tags

This post will look at how we can find resources in Azure using the latest PowerShell modules and replace the Find-AzureRmResource cmdlet which will no longer work.   Note that the commands are not similar and official documentation is limited or not very clear.

The term ‘Find-AzureRmResource’ is not recognized as the name of a cmdlet

The above error will be returned if you try and use the old cmdlet after you have upgraded to V6.0+ of the Azure PowerShell modules.  Remember to also update your Azure Automation modules if you are using this.

So how do we find resources by their tag name AND value using Get-AzureRmResource ?

Well the short answer is first get the resources with the tag NAME you are interested in, and then check the value of that specific tag.

# Brings back all objects with specified tag name, then checks value of specific tag
Get-AzureRmResource -TagName "Autoshutdown" -ResourceType Microsoft.Compute/virtualMachines `
    | where { $_.Tags[‘Autoshutdown’] -ieq "No" } | Select Name, tags

Video Demonstration with Examples



You receive the error The term ‘Find-AzureRmResource’ is not recognized as the name of a cmdlet when you run your script manually or as part of an Azure Automation job.

This means the Azure PowerShell modules have been updated to the latest V6 or higher.  You need to change your code to use Get-AzureRmResource to find your objects.