The Where-Object cmdlet in Azure PowerShell helps you to select objects based on certain conditions. I will walk you through all the possible syntaxes and usage with examples in this article.
Table of Contents
Azure PowerShell Where-Object
This is the basic syntax of Azure PowerShell Where-Object, as mentioned below.
Syntax-1: Basic Syntax
Get-AzStorageAccount | Where-Object { $_.StorageAccountName -eq "azureusanew" }After executing the above command, we got the storage account details named azureusanew successfully as shown below.

Syntax-2: Using wildcard character
The below command will get you the lists of storage accounts whose name starts with “a”.
Get-AzStorageAccount | Where-Object { $_.StorageAccountName -like "a*" }I got the expected output, as shown below.

Syntax-3: Using comparison operators
The PowerShell command below helps you retrieve the lists of storage accounts whose names contain “a”.
Get-AzStorageAccount | Where-Object { $_.StorageAccountName -like "*a*" }After executing the above command, I got the expected output below.

Syntax-4: Using multiple conditions
We can also add multiple conditions with Where-Object as mentioned below.
Get-AzStorageAccount | Where-Object { $_.StorageAccountName -eq "azureusanew" -and $_.Location -eq "eastus" }After executing the above command, I got the expected output as shown in the screenshot below.

Syntax-5: Using date properties
We can also use date properties with Where-Object as mentioned below.
Get-AzStorageAccount | Where-Object { $_.TimeCreated -gt (Get-Date).AddDays(-30) }
Syntax-6: Using methods on properties
Get-AzStorageAccount | Where-Object { $_.Tags.Keys -contains "Apple" }After executing the above command, I got the expected output below.

Conclusion
Azure PowerShell Where-Object is crucial to retrieve the objects based on certain conditions as mentioned in this article.
You may also like following the articles below.
- How To Switch Subscription In Azure PowerShell
- How To Check Azure CLI Version In PowerShell
- How To Get User Object ID In Azure Using PowerShell

I am Rajkishore, and I am a Microsoft Certified IT Consultant. I have over 14 years of experience in Microsoft Azure and AWS, with good experience in Azure Functions, Storage, Virtual Machines, Logic Apps, PowerShell Commands, CLI Commands, Machine Learning, AI, Azure Cognitive Services, DevOps, etc. Not only that, I do have good real-time experience in designing and developing cloud-native data integrations on Azure or AWS, etc. I hope you will learn from these practical Azure tutorials. Read more.
