Missing output in New-UDTable

The dashboard below returns the group membership of an Active Directory user. The output includes the group category which is either Security or Distribution but the table does not show any values for Distribution Groups. Am I missing something here? I have no idea why the table column is blank when I know that the data is there.

Group Data Example

DistinguishedName : CN=ATC First Floor,OU=Distribution Group,DC=DOMAIN,DC=com
GroupCategory : Distribution
GroupScope : Universal
Name : ATC First FLoor
ObjectClass : group
ObjectGUID : 5b23d855-2bd1-4eaa-a1b6-0dbb33453465
SamAccountName : ATC First Floor
SID : S-1-5-21-484763869-1708537768-146503330-68018

New-UDDashboard -Title "Test" -Content {
    New-UDForm -Content {   
        New-UDTextbox -Id txtBox1 -Label 'Enter Domain' -Value 'DOMAIN.COM'
        New-UDTextbox -Id txtBox2 -Label 'Enter SamAccountName'
    } -OnSubmit {
        $domain = Get-UDElement -id txtBox1
        $user = Get-UDElement -id txtBox2
        Show-UDToast -Message $domain.value -Duration 5000
        $adUser = Get-ADUser -Filter "SamAccountName -eq '$($user.value)'" -Server $domain.value
        If($null -eq $adUser) {
            Show-UDToast -Message "$($user.value) is not a valid UPN in the domain $($domain.value)" -Duration 5000
        }
        Else {
            $Groups = Get-ADPrincipalGroupMembership -Identity $adUser -Server $domain.value | Get-ADGroup -Properties Description,GroupCategory | Sort-Object 'GroupCategory', 'Name'
            $Columns = @( 
                New-UDTableColumn -Property Name -Title "Group Name" -IncludeInExport -IncludeInSearch
                New-UDTableColumn -Property GroupCategory -Title 'Type' -IncludeInExport
                New-UDTableColumn -Property GroupScope -Title 'Scope' -IncludeInExport
            )
            New-UDTable -Data $Groups -Id 'GroupTable' -Title "Group Membership for $($adUser.Name)" -Columns $Columns -ShowPagination -ShowExport -ShowSearch -ShowFilter -ShowSort -Dense -PageSize 10
            New-UDButton -Text "Reset" -Icon (New-UDIcon -Icon hand_point_left ) -OnClick {
            Invoke-UDRedirect -Url "$DBUrl/adgm"
            } 
        }    
    }
}

That is very weird.

What is returned when you do $Groups.GroupCategory.GetType()?

I don’t know why this doesn’t happen automatically but you might be able to try to call ToString() in Render.

New-UDTableColumn -Property GroupCategory -Title 'Type' -IncludeInExport -Render { $EventData.GroupCategory.ToString() }

That fixed it.

1 Like