I need to assure that all our resource groups have a specific tag.
I know I can use a policy to ensure that any created resource will have the tag, but for existing resources I'm trying to come up with a query using AZ CLI.
As an extra challenge, the tag has a space in the middle of its name: it is "Cost Center" instead of "CostCenter". :-/
I would recommend using Azure Resource Graph for this. Resource graph allows you to query all your Azure resources using the Kusto language either in the CLI or in the portal.
To look for the name of all resource groups that do not have the "Cost Center" tag you could run a query like:
From the CLI this query would look like: