Iterate over PSObject properties in PowerShell

This is possible using the hidden property PSObject:

$documents.PSObject.Properties | ForEach-Object {
    $_.Name
    $_.Value
}

This won’t work with certain PowerShell-created objects (PSObjects) that contain “NoteProperties” (properties of type NoteProperty).

See this answer for a method that covers all property types.

Leave a Comment