Thanks for the interest so far. here some more info.
$Eventdata only holds the value of the select, but without info about what row it was modified in its useless.
I originally wanted to be able to place a button in each row on a grid. And the button should pass info into a Modal, based on the content of the row.
With @adam’s help, I was able to come up with the code below, and I basically want something similar for UDselect.
@{Name="Details";Expression={
New-UDButton -Text "More" -OnClick (
New-UDEndpoint -Endpoint {
$EmployeeAD = Get-ADUser $($ArgumentList[0]) -Properties Title,Department,AccountExpirationDate,WWWHomePage,msDS-UserPasswordExpiryTimeComputed,PasswordNeverExpires
$Equipment = Invoke-Sqlcmd2 -ServerInstance SQL.Volund.dk\CIMa -Query "
SELECT
[AssetType]
,[AssetManufacturer]
,[AssetModel]
,[AssetSerial]
,[AssetStatus]
,[AssetSystemName]
,[AssetSystemLastSeen]
,[AssetTag]
FROM
[CIMa_Assets].[dbo].[Assets]
Where
[OwnerADObjectGUID]=@OwnerADObjectGUID
" -SqlParameters @{OwnerADObjectGUID = $($($EmployeeAD.ObjectGUID).ToString())}
$TableData = @(
[PSCustomObject]@{Name = "Username"; Value = $($EmployeeAD.SamAccountName); Sort = "1"}
[PSCustomObject]@{Name = "Name"; Value = $($EmployeeAD.Name); Sort = "2"}
[PSCustomObject]@{Name = "Title"; Value = $($EmployeeAD.Title); Sort = "3"}
[PSCustomObject]@{Name = "Department"; Value = $($EmployeeAD.Department); Sort = "4"}
[PSCustomObject]@{Name = "Department Name"; Value = $($EmployeeAD.WWWHomePage); Sort = "5"}
[PSCustomObject]@{Name = "Account Expiration Date"; Value = $(if($EmployeeAD.AccountExpirationDate -eq $null) {"Never"} else {(Get-Date ($EmployeeAD.AccountExpirationDate)).tostring("yyyy-MM-dd HH-mm-ss")}); Sort = "6"}
).GetEnumerator()
Show-UDModal -Header {
New-UDHeading -Size 4 -Text "Here's what we have on $($EmployeeAD.Name)"
} -Content {
New-UDCard -Title "Account Details" -Content {
New-UDTable -Headers @("Attribute", "Value") -Endpoint {
$TableData | Sort-Object Sort | Out-UDTableData -Property @("Name", "Value")
}
}
New-UDCard -Title "Assets" -Content {
New-UDGrid -Headers @("Type","Status","Manufacturer","Model","Serial","SystemName","ID") -Properties @("AssetType","AssetStatus","AssetManufacturer","AssetModel","AssetSerial","AssetSystemName","AssetTag") -PageSize 20 -Endpoint {
$Equipment | Select-Object -Property AssetType,AssetStatus,AssetManufacturer,AssetModel,AssetSerial,AssetSystemName,AssetTag | Out-UDGridData
}
}
}
} -ArgumentList $($_.ObjectGUID)
)
}}