Rakhesh Sasidharan
Rakhesh Sasidharan

Reputation: 1063

ExpandProperty not showing other properties with Select-Object?

I am having trouble with the -expand parameter of select-object cmdlet. I understand from the help file that I can get select-object to output the expanded properties and other properties, but that doesn't seem to be working in my case.

Following an example from the help file, the following works:

PS> Get-Process | select-object Name -expand Modules | fl
Name              : chrome
ModuleName        : chrome.exe
FileName          : C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
BaseAddress       : 10682368
ModuleMemorySize  : 868352
EntryPointAddress : 10980160
FileVersionInfo   : File:             C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
                InternalName:     chrome_exe
                OriginalFilename: chrome.exe
                FileVersion:      28.0.1500.72
...

Trying the same for what I want doesn't work though:

PS> Get-WmiObject Win32_ComputerSystem | select -Property __CLASS,__SUPERCLASS,__DYNASTY -expand __DERIVATION | fl
CIM_UnitaryComputerSystem
CIM_ComputerSystem
CIM_System
CIM_LogicalElement
CIM_ManagedSystemElement

As you can see only the contents of the expanded property are shown; everything else is skipped.

Here's the output without expanding the property:

PS> Get-WmiObject Win32_ComputerSystem | select -Property __CLASS,__SUPERCLASS,__DYNASTY,__DERIVATION | fl


__CLASS      : Win32_ComputerSystem
__SUPERCLASS : CIM_UnitaryComputerSystem
__DYNASTY    : CIM_ManagedSystemElement
__DERIVATION : {CIM_UnitaryComputerSystem, CIM_ComputerSystem, CIM_System, CIM_LogicalElement...}

Any suggestions on what I could be doing wrong or why this isn't working?

Thanks, Rakhesh

Upvotes: 5

Views: 9959

Answers (1)

CB.
CB.

Reputation: 60918

It's by design. You need custom properties. try this:

Get-WmiObject Win32_ComputerSystem |
 select __CLASS,__SUPERCLASS,__DYNASTY,@{n="__DERIVATION";e={($_ | select -expa __DERIVATION) -join ',' }}| fl *

Upvotes: 8

Related Questions