hi
i have a new-udselect i choose a option from then click a button to run queries and have the results output to a new-udgrid
the 1st new-udselect option i choose i can successfully run queries and have the results displayed in a new-udgrid but when i change to the 2nd new-udselect option and run the query new-udgrid only updates with blank values
testing the result variable values with a toast displays the values correctly it just seems the new-udgrid is having an issue updating and displaying the values of the 2nd selectoption
any ideas what i am doing wrong, sample code below
any help much appreciated
#New-udselect
New-UDSelect -Id “actions” -Option {
#new-udselectionoptions
New-UDSelectOption -Name “User Info” -Value “User Info”
New-UDSelectOption -Name “Get PC” -Value “Get PC”
#new-udselect onchange to store value of select in variable
} -OnChange {
$session:selection = (Get-UDElement -Id actions).attributes[“value”]
}
#button onclick
New-UDButton -Text “Submit” -OnClick {
$session:userinput=(Get-UDElement -Id userinput).attributes[“value”]
#run command depending on selectoption chosen
switch($session:selection){
#user info select option onclick
“User Info”{
$session:useroutput = get-aduser -Identity $session:userinput -Properties * | select name, emailaddress, title, distinguishedname, employeeid, enabled, lockedout, passwordexpired, passwordlastset, streetaddress, city, state, postalcode, telephonenumber
$session:useremail = $session:useroutput.emailaddress
$session:useremailurl = “mailto:” + $session:useremail
$session:useremaillink = New-UDLink -Text $session:useremail -Url $session:useremailurl
$session:auserinfo = @(
[PSCustomObject]@{Name=“Soeid”; Value=$session:useroutput.name}
[PSCustomObject]@{Name=“Email”; Value = $session:useremaillink}
[PSCustomObject]@{Name=“Title”; Value = $session:useroutput.title}
[PSCustomObject]@{Name=“OU”; Value = $session:useroutput.DistinguishedName}
[PSCustomObject]@{Name=“Employee ID”; Value = $session:useroutput.employeeid}
[PSCustomObject]@{Name=“Account Enabled”; Value = $session:useroutput.enabled}
[PSCustomObject]@{Name=“Account Locked”; Value = $session:useroutput.lockedout}
[PSCustomObject]@{Name=“Password Expired”; Value = $session:useroutput.passwordexpired}
[PSCustomObject]@{Name=“Password Last Set”; Value = $session:useroutput.passwordlastset}
[PSCustomObject]@{Name=“Street Address”; Value = $session:useroutput.streetaddress}
[PSCustomObject]@{Name=“City”; Value = $session:useroutput.city}
[PSCustomObject]@{Name=“Postal Code”; Value = $session:useroutput.postalcode}
[PSCustomObject]@{Name=“Telephone”; Value = $session:useroutput.telephonenumber}
)
Sync-UDElement -Id “results”
set-UDElement -Id outputbox -content {
New-UDGrid -id “results” -Title “Results” -NoPaging -Headers @(“Name”, “Value”) -Properties @(“Name”, “Value”) -Endpoint {
$session:auserinfo | out-udgriddata
}
}
}
#get-pc info select option onclick
“Get PC”{
$Session:agetpcout = New-Object System.Collections.ArrayList
$session:output = @()
$session:r = Invoke-WebRequest -Uri “http://remotesupportsite.server1.domain.nsroot.net:8083/HD/RDOuser.asp?uid=$session:userinput&p=1&role=detail” -UseDefaultCredentials
$session:data = $session:r.parsedhtml.getelementsbytagname(“table”)[3]
$session:output = ($session:data.innertext)-replace “MyPC." -replace " .”
$session:output = $session:output.trim()
$session:output = $session:output.split()
foreach($device in $session:output){
$Session:agetpcout.Add([PSCustomObject]@{
Device = $device
})
}
$session:check4dvdi = get-aduser session:userinput -Properties memberof | Where-Object {_.memberof -Like “hdvdi” } |select {_.memberof -Like "*hdvdi*" -replace'^cn=|,.*’}
if ($session:check4dvdi){
$Session:agetpcout.Add([PSCustomObject]@{
Device = “Dynamic VDI”
})
Sync-UDElement -Id “results”
set-UDElement -Id outputbox -content {
New-UDGrid -id “results” -Title “Results” -NoPaging -Headers @(“Device”) -Properties @(“Device”) -Endpoint {
$session:agetpcout | out-udgriddata
}
}
}else {
Sync-UDElement -Id “results”
set-UDElement -Id outputbox -content {
New-UDGrid -id “results” -Title “Results” -NoPaging -Headers @(“Device”) -Properties @(“Device”) -Endpoint {
$session:agetpcout | out-udgriddata
}
}
}
}
}
}