4

An object returned from a get-log command can look like

Date: <date>
Properties: 
        statusCode     : OK
        serviceRequestId: 97168d7a-4c92-4d65-b509-65785b14ef42
Name: <name>
Details: <details>

I want to do something that returns that the one object by doing something like

get-log | where-object { $_.Properties.serviceRequestId -eq '97168d7a-4c92-4d65-b509-65785b14ef42' }

Of course, this does not work, but I want something that works like this.

My goal is to see the "Details" property.

0

1 Answer 1

7

The filtering sample you provided works as is:

get-log | where-object { $_.Properties.serviceRequestId -eq '97168d7a-4c92-4d65-b509-65785b14ef42' }

That will return the object(s) you want (the full object, not just inner properties).

So you can use the result of that to get at any other property, like Details:

$result = get-log | where-object { $_.Properties.serviceRequestId -eq '97168d7a-4c92-4d65-b509-65785b14ef42' }
$result.Details

Or you can do it all in one line by continuing the pipeline and using Select-Object:

get-log | 
    where-object { 
        $_.Properties.serviceRequestId -eq '97168d7a-4c92-4d65-b509-65785b14ef42' 
    } |
    Select-Object -ExpandProperty Details

(did it on multiple lines for better readability)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.