All,
I have a block of code I pulled from the interwebs and modified for my needs that is providing exactly what I expect. This outputs data (Properties/Values) that I would like to work with. However, I can’t seem to find a way to parse the output.
Because I have had such trouble with this, I ran $a.GetType() to figure out what I am working with. That says this is an Object with a BaseType of System.Array. That seems to indicate that this is an Object and an Array. But I can’t seem to filter or pull properties or values out of this output in any way.
What am I missing?
Your problem is that the loop contains a Format-* cmdlet so $a references formatted data, not the object(s) being created in the loop. Remove the | and Format-Table cmdlet and then you can access $a.propertyName
Edit: Well that’ll teach me to test before posting…
It requires a bit more modification to access by property name.
Thanks @matt-bloomfield. I like how this produces the same output as my original, but with fewer lines. I will use that for learning. However, I am seeing the same issue with my attempts to pull data from that output. For example, trying to grab the Name and Value for InstalledDate so it could be used downstream.
$a. just complains that the property does not exist.
@krzydoug perhaps that is the issue. If it is, I don’t understand. The properties that list in $a are within the key ‘KB4087364’. This is how the variable gets populated so I can read it in the console. But any attempt to use ‘$a.anything’ is met with an error about no property.
This is really narrowing down the core issue. I can get the data I want written to a variable, but not work with any of that data.
Could you please stop posting pictures of code or console output? That’s not helpful. Just format it as code just like you did it in your initial post.