0

I've an array with 10 values (0 to 9). Each array value output is a multi-liner. Here is what it looks like for example -

C:>arrval[0]
12345
34593433598434
error1
357948557
C:>arrval[1]
238296879234
error1
93454753503
error2

I'm checking to see if we can print only the error portion in an array value.

1 Answer 1

1

Something like this?

$arrval -split "`n" |  where {$_ -like "*error*"}
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for trying! It prints the whole array value. I'm already filtering the array values using Select-String. It results only the array values that has errors.
Put an output example please
Please ignore the above comment. I accidentally hit enter. Here is an output example - error1 error1 error2
Sorry, yes. I agree! I was using foreach ($error in $arrval){ $error -split "n" | where {$_ -like "error"}}. In this scenario, $error.gettype() returns system.object` where $arrval.gettype() returns System.Array. Looks like that's the problem? :|

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.