The results of each Azure PowerShell cmdlet are an Azure PowerShell object. Even cmdlets that aren't
explicitly Get- operations might return a value that can be inspected, to give information about a
resource that was created or modified. While most cmdlets return a single object, some return an
array that should be iterated through.
Usually, you query output from Azure PowerShell with the
Select-Object cmdlet. Output can be
filtered with Where-Object.
Select simple properties
In the default table format, Azure PowerShell cmdlets don't display all their available properties.
You can get the full properties using the
Format-List cmdlet, or by piping
output to Select-Object -Property *:
Name VmId ProvisioningState
---- ---- -----------------
TestVM 00000000-0000-0000-0000-000000000000 Succeeded
Output from using Select-Object is always formatted to display the requested information. To learn
about using formatting as part of querying cmdlet results, see
Format Azure PowerShell cmdlet output.
Select nested properties
Some properties in Azure PowerShell cmdlet output use nested objects, like the StorageProfile
property of Get-AzVM output. To get a value from a nested property, provide a display name and the
full path to the value you want to inspect as part of a dictionary argument to Select-Object:
Name OSType
---- ------
TestVM Linux
TestVM2 Linux
WinVM Windows
Each dictionary argument selects one property from the object. The property to extract must be part
of an expression.
Filter results
The Where-Object cmdlet allows you to filter the result based on any property value, including
nested properties. The next example shows how to use Where-Object to find the Linux VMs in a
resource group.
ResourceGroupName Name Location VmSize OsType NIC ProvisioningState Zone
----------------- ---- -------- ------ ------ --- ----------------- ----
TestGroup TestVM westus2 Standard_D2s_v3 Linux testvm299 Succeeded
TestGroup TestVM2 westus2 Standard_D2s_v3 Linux testvm2669 Succeeded
You can pipe the results of Select-Object and Where-Object to each other. For performance
purposes, it's always recommended to put the Where-Object operation before Select-Object: