Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json Export does not export childgroups correctly #18

Open
bateskevin opened this issue Apr 17, 2024 · 1 comment
Open

Json Export does not export childgroups correctly #18

bateskevin opened this issue Apr 17, 2024 · 1 comment

Comments

@bateskevin
Copy link
Collaborator

bateskevin commented Apr 17, 2024

The current json export does not export the child groups correctly. In the loop on line 635 in the module it only loops through the first groupname and disregards all other groups:

foreach($Group in $this.GroupCollection.groups.name){
                $RootHashTable.$Group = @{}
                if(($this.GroupCollection.Groups | ?{$_.name -eq $Group} | select members).members -gt 0){
                    $RootHashTable.$Group.hosts = ($this.GroupCollection.Groups | ?{$_.name -eq $Group} | select members).members
                }
                if($this.Hierarchy.Entries.Parent -contains $Group){
                    foreach($Hierarchyentry in $this.Hierarchy.Entries){
                        if($null -eq $Hierarchyentry.children){
                            $RootHashTable.$($Hierarchyentry.Parent) = @{}
                            $RootHashTable.$($Hierarchyentry.Parent).children = @()
                        }else{
                            $RootHashTable.$($Hierarchyentry.Parent).children = ($this.Hierarchy.Entries | ?{$_.Parent -eq $($Hierarchyentry.Parent)}).Children 
                        }
                    }
                    
                    $RootHashTable.$Group.Remove("hosts")
                }
            }
@bateskevin
Copy link
Collaborator Author

The problem was that cases for child groups were not handled. I have added it and also fixed some conditionals in the code that did not return what I expected them to initially.

bateskevin pushed a commit that referenced this issue Apr 17, 2024
…nsideration for array as default null value
bateskevin pushed a commit that referenced this issue Apr 17, 2024
…nsideration for array as default null value
Stephanevg added a commit that referenced this issue Apr 17, 2024
fixing issue #18, json structure was not taking child groups in to consideration for array as default null value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant