8

Trying to execute a Select-Object, but i can't seem to return property and a value from a key-value list property. There are 3 properties i want returned RunStart, Message and 'tableName' from this Parameters property.

I get too much with this:

|Select-Object -Property Parameters,RunStart,Message

Parameters                                    RunStart              Message
----------                                    --------              -------
{[tableName, AHROR012], [schemaName, dbo]...} 11/14/2019 5:39:06 PM Operation on target failed

But I dont get the RunStart or Message when i do this:

|Select-Object -ExpandProperty Parameters -Property tableName,RunStart,Message

Key                 Value
---                 -----
tableName           AHROR012

How do i do it to get:

Parameters.tableName                         RunStart              Message
----------                                    --------              -------
AHROR012                                      11/14/2019 5:39:06 PM Operation on target failed

THANKS!!!

mklement0
  • 382,024
  • 64
  • 607
  • 775
Jared Tims
  • 191
  • 1
  • 1
  • 9

2 Answers2

8
... | Select-Object -Property @{
      Name='ParametersTableName';
      Expression={ $_.Parameters.tableName }
    }, RunStart, Message
mklement0
  • 382,024
  • 64
  • 607
  • 775
Kamil
  • 96
  • 1
-2

A more elegant solution would be to use a 2nd select statement:

... | select RunStart,Message -ExpandProperty Parameters | Select RunStart,Message,tableName

NitrusCS
  • 597
  • 1
  • 5
  • 20