Skip to content

Hashtable into Get-AzResource -Tag $QueryTag returns results as if it's OR instead of AND #19387

Open
@nofate301

Description

@nofate301

Description

So I have a hashtable of tags and values that I know are on a virtual machine in the environment.

$QueryTags = @{"Technical:AlwaysPatch" = "yes"; "Technical:PatchingOwner" = "NamedPerson";"Technical:PatchingSchedule" = "Default"; "Technical:Environment" = "NONPROD"}

When I do Get-AzResource -Tag $QueryTags I get a response with all the resources in the subscription.

The problem is there's only one virtual machine in the subscription that has this combination of tags. Nothing in the documentation indicates that the -Tag parameter is an OR or AND function. I thought it would be an AND function like the query section from New-AzAutomationUpdateManagementAzureQuery.

Is there something I'm missing?

Script or Debug output

No response

Environment data

Name                           Value                                                                                                                                                                                                     
----                           -----                                                                                                                                                                                                     
PSVersion                      5.1.19041.1682                                                                                                                                                                                            
PSEdition                      Desktop                                                                                                                                                                                                   
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                                                   
BuildVersion                   10.0.19041.1682                                                                                                                                                                                           
CLRVersion                     4.0.30319.42000                                                                                                                                                                                           
WSManStackVersion              3.0                                                                                                                                                                                                       
PSRemotingProtocolVersion      2.3                                                                                                                                                                                                       
SerializationVersion           1.1.0.1

Module versions

PS C:\WINDOWS\system32> Get-Module Az*

ModuleType Version    Name                                ExportedCommands                                                                                                                                                               
---------- -------    ----                                ----------------                                                                                                                                                               
Script     2.9.1      Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault...}                                                                                                       
Script     6.1.0      Az.Resources                        {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, Get-AzDeployment...}

Error output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    ARM - CoreService AttentionThis issue is responsible by Azure service team.customer-reportedquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions