Find Azure resources missing required tags
Documentation: Microsoft Learn
Inspect Azure resource tags with Get-AzResource and identify resources missing required keys before planning any changes.
The script
Script reader
Inspect before you run
Inspect the script below. It does not run in this browser.
Inspection only — no command has run.
Show reference output
Inspect this example’s structure
Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.
$required = 'Owner', 'Environment', 'CostCenter'
Get-AzResource | ForEach-Object {
$resource = $_
$missing = $required | Where-Object {
-not $resource.Tags -or
-not $resource.Tags.ContainsKey($_) -or
[string]::IsNullOrWhiteSpace($resource.Tags[$_])
}
if ($missing) {
[pscustomobject]@{
ResourceGroup = $resource.ResourceGroupName
Name = $resource.Name
Type = $resource.ResourceType
MissingTags = $missing -join ', '
}
}
} | Sort-Object ResourceGroup, Name- Stage 1$required
Positional values or no named parameters - Stage 2ForEach-Object
Positional values or no named parameters - Stage 3Sort-Object
Positional values or no named parameters
How it works
Inspect Azure resource tags with Get-AzResource and identify resources missing required keys before planning any changes. Each resource is checked against one explicit required-tag list, and only gaps become output. Keeping discovery separate from remediation makes the report safe to run during governance reviews.
Adapting it
Replace the required list with your policy names or load it from configuration. Scope Get-AzResource to a subscription or resource group when the tenant is large.
Primary documentation
Where-Object reference · ForEach-Object reference · Sort-Object reference