PSPHPIPAM icon indicating copy to clipboard operation
PSPHPIPAM copied to clipboard

Getting full subnet hierarchy, including folders from Get-PhpIpamSubnets

Open jeverett-syl opened this issue 1 year ago • 0 comments

Is it possible to get the full subnet hierarchy, including folders from Get-PhpIpamSubnets?

Looking in the phpIPAM web UI, each subnet view has a "Hierarchy" display like: Hierarchy | Section / Folder / Folder / Supernet (CIDR) / Subnet (CIDR)

Get-PhpIpamSubnets seems to return a sectionId and masterSubnetId which gets me some info, and I can construct fields like, say:

Get-PhpIpamSubnets |
Select-Object `
    @{Name = 'Subnet'; Expression = {$_.subnet+"/"+$_.mask}},
    @{Name = 'Section'; Expression = {(get-PhpIpamSection -id ([int]($_.sectionId))).name}},
    @{Name = 'Supernet_Description'; Expression = {if($_.masterSubnetId -and $_.masterSubnetId -ne 0 ){(Get-PhpIpamSubnet ([int]$_.masterSubnetId)).description}}},
    @{Name = 'Supernet'; Expression = {if($_.mastersubnetid -and $_.masterSubnetId -ne 0){(Get-PhpIpamSubnet ([int]$_.masterSubnetId)).subnet +"/"+ (Get-PhpIpamSubnet ([int]$_.masterSubnetId)).mask}}}

However, it doesn't seem like masterSubnetId registers folders, just supernets above the subnet, nor do I see any other properties returned related to folders.

Is that data just not returned by the API? If so, is there any other approaches possible to get the full hierarchy output for a subnet.

Thanks!

jeverett-syl avatar Nov 02 '23 20:11 jeverett-syl