<p>There are at least two ways to achieve this.</p>

<p>First is to go with transforming json output to proper object for PowerShell as described in this thread:</p>

<ul>
<li><a href="https://stackoverflow.com/questions/58738011/how-do-you-select-just-one-property-from-an-array-of-results-from-the-azure-co">how do you select just one property from an array of “results” from the Azure command 'az group list in powershell'?</a></li>
</ul>

<p>Second it to use <code>--query</code> global parameter for Azure CLI:</p>

<pre><code>az group list --query "[?contains(name,'kafka')].name"
</code></pre>

<p>But remember to use at least PowerShell 6.2 as previous versions have an issue:</p>

<ul>
<li><a href="https://github.com/Azure/azure-cli/issues/9047" rel="nofollow noreferrer">powershell --query error #9047</a></li>
</ul>

CC BY-SA 4.0
2020-04-10T21:06:22.627Z
2020-04-10T21:06:22.627Z
Paweł Tajs
<p>I set my az account to current subscription. And I am trying to fetch the resource name ending with (example "***kafka" ). How can i do it. </p>

<p>I tried with <code>az group list -n '***kafka'</code></p>

<blockquote>
  <p>validation error: Parameter 'resource_group_name' must conform to the following pattern: '^[-\w\._\(\)]+$'.</p>
</blockquote>

<azure>
How to fetch resource group name( with pattern matching) using Azurecli
Rocky Hai
# How to fetch resource group name( with pattern matching) using Azurecli

(Asked by: username_0 on 2020-03-12)

I set my az account to current subscription. And I am trying to fetch the resource name ending with (example "\*\*\*kafka" ). How can i do it.

I tried with `az group list -n '***kafka'`

> validation error: Parameter 'resource\_group\_name' must conform to the following pattern: '^[-\w\.\_\(\)]+$'.

**Tags:** azure


---

## 1 answers

### Answer by username_1 on 2020-04-10. Score: 2 | Accepted answer

There are at least two ways to achieve this.
First is to go with transforming json output to proper object for PowerShell as described in this thread:

how do you select just one property from an array of “results” from the Azure command 'az group list in powershell'?

Second it to use --query global parameter for Azure CLI:
az group list --query "[?contains(name,'kafka')].name"

But remember to use at least PowerShell 6.2 as previous versions have an issue:

powershell --query error #9047


---

