Iterate over PSObject properties in PowerShell
<p>I have this <code>PSObject</code> (from XML):</p>

<pre><code>bool : {IsActive, ShowOnB2C, ShowOnB2B, IsWebNews}
str  : {id, ProductId, GroupName, Unit...}
int  : {ProductIdNumeric, Prices_SalesOne, Prices_Treater, Prices_B2C...}
arr  : {EnvironmentBrands, Catalogs, NavisionLevels}
long : long
</code></pre>

<p>I would like to iterate over the properties without using the property names, for instance <code>bool</code>.</p>

<p>I have tried to index into the object like this:</p>

<pre><code>$document[0]
</code></pre>

<p>But that gives me nothing, but it does not cause any errors either.</p>

<p><code>Select-Object</code> kind of works, but then I have to use the property names, and I don't want that.</p>

<pre><code>$documents | Select-Object bool,str
</code></pre>

<p><code>ForEach</code> do not iterate the properties.</p>

<pre><code>$documents | ForEach {
    $_.name
}
</code></pre>

<p>returns doc and that is the name of the tag (XML) holding the bools, ints, and strings.</p>