Select-Object -expandproperty SomeArray

Hi,

can anyone please tell me the short version of expanding values in an array (property with squiggly brackets and lots of values in it)?

For example,
Get-CompInfo -ComputerName MyPC | Select-Object -expandproperty DiskInfo

How do I shorten the second part of the command after the pipe?

I’ve seen someone do it somewhere in some video demo but I can’t remember.

Thank you very much

(Get-CompInfo -ComputerName MyPC).DiskInfo

Sean’s example is a implicit loop, which requires Powershell v3 or higher. Rather than doing this:

Get-CompInfo -ComputerName MyPC | foreach{$_.DiskInfo}

the implicit foreach was provided as a shortcut to do the same thing.

Thank you good people.

@Rob

Get-CompInfo -ComputerName MyPC | % DiskInfo

That’s what I saw in some video! I remembered now once I saw your “foreach{$_.DiskInfo}”.

thank you