How to "select" for an array of strings

When I use Select-Object NameCmdLet, a new object is created with a single property Name.

I often want to pass this selection to other CmdLets, but they often only accept a string.

How can I easily get a bunch of objects and say "Select only property x and only property values ​​in an array or a set of only its values"?

+4
source share
1 answer

You can use the parameter for this ExpandProperty. This switch means that instead of returning an object with the properties specified in the parameter (default) -Properties, the value of the only property specified in the parameter is returned -ExpandProperty.

. expand .

:

Get-Process | Select-Object -ExpandProperty ProcessName

:

+6

Source: https://habr.com/ru/post/1683738/


All Articles