'How can I access Powershell PSCustomObject properties?

I'm processing through Powershell script some API result processing. API data (json) come from this :

$tree = Invoke-WebRequest -Uri "xxxxxxxxmonURLxxxxxxxxxx/130333"  
$children = ($tree.Content | ConvertFrom-Json).data.12345.children

Then I loop through $children object using | ForEach $_ within loop has "147852" as $_.Name, and the following object as $_.Definition I'd like to parse the object within $_.Definition but cannot figure out how to access it.

The Definition object looks like this:

  TypeName : System.Management.Automation.PSCustomObject
 
Name   MemberType   Definition
----   ----------   ----------
147852 NoteProperty System.Management.Automation.PSCustomObject 147852=@{nodeType=node; name=test1; flag=N0; creationDate=2022-02-17T14:50:16+00:00; hasAlerts=False; children=}

And I wish to access any property within the 147852 key (such as nodeType, name, flag, ..., children).

$_.147852 outputs an error saying 147852 was not found.

Thanks.

API json returned:

{
    "data": {
        "130333": {
            "nodeType": "node",
            "name": "Test name",
            "flag": "N0",
            "children": {
                "147852": {
                    "nodeType": "node",
                    "name": "test1",
                    "flag": "N0",
                    "hasAlerts": false,
                    "children": {
                        "147853": {
                            "nodeType": "node",
                            "name": "test2",
                            "flag": "N0",
                            "children": {
                                "NP12-N9-S4": {
                                    "nodeType": "agent",
                                    "name": "Win10",
                                    "type": "S"
                                }
                            }
                        }
                }
            }
        }
    }
} 


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source