Hi @BoSen29 I’m just getting around to testing Select-UDElement in my dashboard. So far I have not been able to get it to work. I wasn’t sure if I should create a new post or reply here. If you prefer I open a new post just let me know. Anyway I was hoping you could take a look at this and let me know if I am missing anything. Thanks in advance!
Here is a snippet of code where I am calling Select-UDElement.
New-UDCard -Title "User Account Search" -BackgroundColor '#eeeeee' -Content {
New-UDIcon -Icon search -Size 4x
New-UDInput -Title "Search" -SubmitText "Search" -Endpoint {
param(
[Parameter(Mandatory=$false)]
[ValidateCount(1,20)]
[string]$FirstName,
[Parameter(Mandatory=$false)]
[ValidateCount(1,20)]
[string]$LastName
)
$Session:FirstName = $FirstName
$Session:LastName = $LastName
$Session:RequestingUser = $user
New-UDInputAction -Content {
New-UDGrid -NoExport -Title "" -Headers @("Name", "UserName", "Enabled", "Options") -Properties @("Name", "UserName", "Enabled", "Button") -Endpoint {
$Cache:ADUser | Where-Object { ($_.GivenName -match $Session:FirstName) -or ($_.SurName -match $Session:LastName) } | ForEach-Object {
[PSCustomObject]@{
Name = $_.Name
UserName = $_.SamAccountName
Enabled = $_.Enabled
Button = New-UDButton -Text "Select User" -Icon user_edit -OnClick (New-UDEndpoint -Endpoint {
$Session:SelectedUserSAN = $_.SamAccountName
$Session:SelectedUserName = $_.Name
$Session:GridData = Invoke-ADUMUEGridData -SamAccountName $Session:SelectedUserSAN
$Session:ObjectGUID = $_.ObjectGUID
$Session:UsersGroupsList = (Get-ADPrincipalGroupMembership -Identity $Session:SelectedUserSAN | Select-Object -Property SamAccountName).SamAccountName
#Sync/update table and cards to show infor for currently selected user
Sync-UDElement -Id 'DivBox2'
})#end new-udendpoint in pscustomobject
}#end psobject
} | Select-Object -Property Name, UserName, Enabled, button | sort Name | Out-UDGridData
}#end udgrid endpoint
}#end udinputAction content
New-UDInputAction -Content {
Select-UDElement -ID 'UserHealthTable'
}
}#end udinput endpoint
}#end udcard search
Here is my target element that is lower down on the same page.
New-UDTable -Id 'UserHealthTable' -AutoRefresh -RefreshInterval 60 -Headers @("DisplayName","UserName","EmployeeID","Email","Title","Department","AccountLocked","AccountExpired","AccountEnabled","PasswordExpired","PasswordLastSet","LastBadPasswordAttempt","LastLogonDate","AccountCreated") -Endpoint {
if ($null -ne $Session:GridData) {
$Session:GridData | Out-UDTableData -Property @("DisplayName","UserName","EmployeeID","Email","Title","Department","AccountLocked","AccountExpired","AccountEnabled","PasswordExpired","PasswordLastSet","LastBadPasswordAttempt","LastLogonDate","AccountCreated")
}#end if
}#end udtable
FYI this is not the full code on the page, it’s just the sections I thought are relevant. If you need the whole thing I can share the rest.