liveBook · Manning

-expandproperty

As explained in Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS

-ExpandProperty is a Select-Object parameter that outputs the values of a specified property instead of objects containing that property.

Select-Object -ExpandProperty extracts the values of a named property and sends those simple values through the pipeline instead of returning objects that merely contain the property. section 10.8

Pass a resource-group name to another cmdlet

Get-AzResourceGroup -Location westus2 | Select-Object -First 1 -ExpandProperty ResourceGroupName returns a resource-group name as a string. That value can feed New-AzStorageAccount -ResourceGroupName, unlike the original PSResourceGroup object or a custom object made with -Property. section 10.8

See the difference

Compare Get-Date | Select-Object -Property DayOfWeek with Get-Date | Select-Object -ExpandProperty DayOfWeek: the first produces an object containing DayOfWeek, while the second outputs the property value. section 10.11

How Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS covers it

How deep it goes
Explains object-versus-value output and parameter compatibility, while stopping short of deeper pipeline internals.
Examples
Demonstrates DayOfWeek extraction, Azure resource-group names, storage-account creation, and file-name comparison.
What it assumes
Assumes familiarity with basic pipelines and properties, while teaching why object types must match parameter expectations.
What you can do after
Apply it to extract values that can be passed to cmdlets expecting strings instead of richer objects.
How it connects
Connects Select-Object with pipelines, object types, Get-Member, and parameter binding.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS. The section links point to the parts of the book it draws on.