Get-Aduser & New-UDTable

Product: PowerShell Universal
Version: 3.6.3

Hi,

Im trying to create a PoC for PSU, to replace an internal legacy tool.
But im stuck on the New-UDTable function.

My goal is to have multiple pages, where the supporter clicks on a button, that then fx performs

Get-aduser -filter "Enabled -eq '$false'"

→ Lets the supporter select the user → Enters a custom auto reply in the text field → Click ok and then the username & custom text is then forwarded to an API or script, that then connects to O365.

The button is there, but when i click it, nothing happens - could you provide some guidance / what functions i need to use / etc?

$Navigation = @(
    New-UDList -Children {
        New-UDListItem -Label "HomePage"
        New-UDListItem -Label "Menus" -Children {
            New-UDListItem -Label "O365" -Children {
                New-UDListItem -Label "Set Auto Reply" -Href '/poc/O365/SetAutoReply'
            }
            New-UDListItem -Label "ActiveDirectory" -Children {
                New-UDListItem -Label "Enable user" -Href '/poc/ActiveDirectory/EnableUser'
            }
        }
    }
) 

$Columns = @(
    New-UDTableColumn -Property Name -Title "Name" -ShowFilter
    New-UDTableColumn -Property SamAccountName -Title "SamAccountName" -ShowFilter
)

$Pages = @()
$Pages += New-UDPage -Name 'Support tool - web edition' -Url '/poc/Home' -Content {
    Show-UDToast -Message "support" -Duration 3000
} -NavigationLayout permanent -Navigation $Navigation
#O365
$Pages += New-UDPage -Name 'O365' -Url '/poc/O365/SetAutoReply' -Content {
    New-UDButton -Text "Load all eligible users" -OnClick { 
        $Data = Get-aduser -filter "Enabled -eq '$true'" 
        New-UDTable -Columns $Columns -Data $Data -ShowSearch 
    } 
} -NavigationLayout permanent -Navigation $Navigation
#ActiveDirectory
$Pages += New-UDPage -Name 'ActiveDirectory' -Url '/poc/ActiveDirectory/EnableUser' -Content {
    New-UDButton -Text "Load all eligible users" -OnClick { 
        $Data = Get-aduser -filter "Enabled -eq '$false'" 
        New-UDTable -Columns $Columns -Data $Data -ShowSearch 
    } 
} -NavigationLayout permanent -Navigation $Navigation

New-UDDashboard -Pages $Pages -Title 'Dashboard' -HeaderContent {
    New-UDButton -Text 'Guide' -Icon (New-UDIcon -Icon Users) -OnClick {
        Invoke-UDRedirect https://google.com
    } -Color info
    New-UDButton -Text 'Learn More' -Icon (New-UDIcon -Icon Book) -OnClick {
        Invoke-UDRedirect https://github.com
    } -Color info
}

You can’t return a component from a button like this. You could so something like:

New-UDDynamic -Id 'userTable' -Content {
}

    New-UDButton -Text "Load all eligible users" -OnClick { 
        Set-UDElement -Id 'userTable' -Content {
           $Data = Get-aduser -filter "Enabled -eq '$true'" 
           New-UDTable -Columns $Columns -Data $Data -ShowSearch 
        }
    }