React error when trying to build list of buttons [Solved]

@aggiebeckett
Judging from the logfile, your original solution sent the groupname in CLIXML. Could probably just .tostring it in the text

Ie -text $somevar.tostring()

So I was able to get it fixed using the string method. I’m still confused on what changed between the most recent release and 2.6.2 that caused this to break. But this fix should work for all of my broken tools currently. I really appreciate everyone help with this.

Final Code:

      New-UDCard -Title "Single Group Removal" -Content {
          New-UDInput -Title "Enter NetID" -Content {
              New-UDInputField -Type textbox -Name 'NewUser' -Placeholder "Enter New Users NetID"
          } -Endpoint {
              param($newuser)   
              $Cache:strSIDusr,$strusr = Get-Sid -netid $newuser
              $Cache:newuser = $newuser
              [array]$grpstr =  Get-ADGroup -Filter {member -eq $strusr} | Select-Object -ExpandProperty Name
              [array]$Session:fgp = Get-ADGroup -filter {name -like "*" -and member -eq $strusr} | Select-Object -ExpandProperty distinguishedName
              $grpArray = @()
              foreach ($grp in $grpstr){
                  $grpArray += [string]$grp      
              }
              New-UDInputAction -Content @(
                  New-UDCard -Title "Select Groups to Remove User Access From:" -Content {
                      for($i=0; $i -lt $grpstr.Length;$i++) {
                          New-UDButton -Text $grpArray[$i] -OnClick(
                              New-UDEndpoint -Endpoint{
                                $group = New-Object DirectoryServices.DirectoryEntry("LDAP://$($Session:fgp[$ArgumentList[0]])")
                                [void]$group.member.Remove("<SID=$($ArgumentList[1])>")
                                $group.CommitChanges()
                                $group.Close()
                                $gname = $grpArray[$ArgumentList[0]]
                                Show-UDToast -Message "User Removed to Group"   
                                Add-Content -Path $Cache:logpath -Value "$Cache:DateString - $User removed $Cache:newuser from $gname" 
                              } -ArgumentList @($i,$Cache:strSIDusr)
                            )  
                      }
                  } -Links @(
              New-UDLink -Text 'Reset' -Url 'React-Testing'
              ) 
              )
          }
      }

I also remembered why I had to build the New-UDEndpoint into the button. It was because I couldn’t get the variables to pass properly without them. So building them back in fixed the other issue.

1 Like