Active directory dashboard

long story short: me and a friend got a project at an internship to create a dashboard. now the problem is we need to make a dashboard that can connect to other servers that are not linked together. we are doing this with the AD module we imported from that server so we can search for users and add users.
we tried the UD-AD module first but this didn’t want to work. so we (me and my friend who are complete noobs at powershell) butchered the code of the UD-AD to try to make it work. but the furthest we got was adding users with an error but they are still being added but the important part: we can find users but can’t press more info or we get the “Variable: ‘Identity’ found in expression: $Identity is not defined.” is there a solution?
my code:
Import-Module ActiveDirectory
Import-Module UniversalDashboard

function Start-adtest {
param(
[Parameter(Mandatory)]
[string]$Server,
[Parameter(Mandatory)]
[PSCredential]$Credential
)

$Cache:Loading = $true
$Cache:ChartColorPalette = @('#5899DA', '#E8743B', '#19A979', '#ED4A7B', '#945ECF', '#13A4B4', '#525DF4', '#BF399E', '#6C8893', '#EE6868', '#2F6497')
$Cache:ConnectionInfo = @{
    Server = $Server
    Credential = $Credential}

$object = New-UDPage -Url “/object/:identity” -Endpoint {
param($identity)
$Object = Get-ADObject -Filter { Name -eq $Identity } @Cache:ConnectionInfo -Properties ObjectClass -IncludeDeletedObjects
if ($Object.ObjectClass -eq “user”)
{
$Object = Get-ADUser -Filter { Name -eq $Identity } @Cache:ConnectionInfo -Properties *
}
elseif ($Object.ObjectClass -eq “computer”)
{
$Object = Get-ADComputer -Filter { Name -eq $Identity } @Cache:ConnectionInfo -Properties *
}
elseif ($Object.ObjectClass -eq “group”)
{
$Object = Get-ADGroup -Filter { Name -eq $Identity } @Cache:ConnectionInfo -Properties *
}
else
{
$Object = Get-ADObject -Filter { Name -eq $Identity } @Cache:ConnectionInfo -Properties * -IncludeDeletedObjects
}

New-UDRow -Columns {
    New-UDColumn -Size 4 -Content {
        New-UDCard -Title $Object.DisplayName -Content {
            New-UDRow -Columns {
                New-UDColumn -Size 4 -Content {
                    New-ADIcon -ObjectClass $Object.ObjectClass -Size 5x
                }
                New-UDColumn -Size 8 -Content {
                    New-UDHeading -Size 5 -Text ($Object.GivenName + " " + $Object.SurName)
                    New-UDHeading -Size 5 -Text $Object.SamAccountName
                }
            }
        }
    }

    if (-not $Object.Deleted)
    {
        New-UDColumn -Size 4 -Content {
            New-UDElement -Tag "div" -Attributes @{ style = @{ height = "10px"}}
            New-UDButton -Icon trash -Text "Delete" -OnClick {
                Show-UDModal -Header { New-UDHeading -Size 5 -Text "Are you sure you want to delete this object?" } -Content {

                    New-UDHeading -Size 5 -Text "Clicking ok will run: Remove-ADObject -Identity $($Object.samAccountName) -Confirm:`$false"

                    New-UDRow -Columns {
                        New-UDColumn -Size 2 -Content {
                            New-UDButton -Text "Ok" -OnClick {
                                Remove-ADObject -Identity $Object.samAccountName @Cache:ConnectionInfo -Confirm:$false
                                Hide-UDModal
                                Invoke-UDRedirect -Url "/home"
                            } -Icon warning
                        }
                        New-UDColumn -Size 2 -Content {
                            New-UDButton -Text "Cancel" -OnClick {
                                Hide-UDModal
                            }
                        }
                    }
                }
            }

            if ($Object.ObjectClass -eq "user" -or $Object.ObjectClass -eq "computer")
            {
                $EnabledText = "Enable"
                $btnIcon = 'check'
                if ($Object.Enabled)
                {
                    $EnabledText = "Disable"
                    $btnIcon = 'xing'
                }

                New-UDElement -Tag "div" -Attributes @{ style = @{ height = "10px"}} -Content {}
                New-UDButton -Id "btnEnabled" -Icon $btnIcon -Text $EnabledText  -OnClick {
                    if ($Object.Enabled)
                    {
                        $Object.Enabled = $(Disable-ADAccount -Identity $Object.samAccountName @Cache:ConnectionInfo -PassThru).Enabled
                        Set-UDElement -Id "btnEnabled" -Content {
                            New-UDIcon -Icon 'check'
                            "Enable"
                        }
                    }
                    else
                    {
                        $Object.Enabled = $(Enable-ADAccount -Identity $Object.samAccountName @Cache:ConnectionInfo -PassThru).Enabled
                        Set-UDElement -Id "btnEnabled" -Content {
                            New-UDIcon -Icon 'xing'
                            "Disable"
                        }
                    }
                }
            }
        }
    }


}

if ($Object.ObjectClass -eq 'user')
{
    New-UDRow -Columns {
        New-UDColumn -SmallSize 12 -Content {
            New-UDCollapsible -Items {
                New-UDCollapsibleItem -Title "Reset Password" -Icon star_half_o -Content {
                    New-UDInput -Title "Reset Password" -SubmitText "Reset" -Content {
                        New-UDInputField -Name "Password" -Placeholder "Password" -Type "password"
                    } -Endpoint {
                        param($Password)

                        try
                        {
                            Set-ADAccountPassword -Reset -NewPassword (ConvertTo-SecureString -AsPlainText -String $Password -Force) -Identity $identity @Cache:ConnectionInfo
                            New-UDInputAction -Toast "Password Reset" -Duration 3000
                        }
                        catch
                        {
                            New-UDInputAction -Toast "$_" -Duration 3000
                        }
                    }
                }
            }
        }
    }
}

if ($Object.ObjectClass -eq 'group')
{
    New-UDRow -Columns {
        New-UDColumn -SmallSize 12 -Content {
            New-UDCollapsible -Items {
                New-UDCollapsibleItem -Title "Members" -Icon users -Content {
                    New-UDTable -Id "members" -Headers @("Name", "Remove") -Endpoint {
                        Get-ADGroupMember -Identity $identity @Cache:ConnectionInfo | ForEach-Object {
                            $member = $_
                            [PSCustomObject]@{
                                Name   = $_.name
                                Remove = New-UDButton -Text "Remove" -OnClick {
                                    Remove-ADGroupMember -Identity $identity @Cache:ConnectionInfo -Members $member -Confirm:$false
                                }
                            }
                        } | Out-UDTableData -Property @("Name", "Remove")
                    } -AutoRefresh -RefreshInterval 5
                }
            }
        }
    }
}

New-UDRow -Columns {
    New-UDColumn -Size 12 -Content {
        New-UDTable -Title "Attributes" -Headers @("Name", "Value") -Endpoint {

            $SkippedProperties = @("PropertyNames", "AddedProperties", "ModifiedProperties", "RemovedProperties", "PropertyCount")

            $Object.psobject.Properties | ForEach-Object {

                if ($SkippedProperties.Contains( $_.Name))
                {
                    return
                }

                $Value = $Null
                if ($_.Value -eq $null)
                {
                    $Value = ' '
                }
                elseif ($_.Value -is [Microsoft.ActiveDirectory.Management.ADPropertyValueCollection])
                {
                    $Value = ($_.Value | ForEach-Object {
                            $_.ToString()
                            New-UDElement -Tag "br"
                        })
                }
                else
                {
                    $Value = $_.Value.ToString()
                }

                [PSCustomObject]@{
                    Name  = $_.Name
                    Value = $Value
                } | Out-UDTableData -Property @("Name", "Value")
            }
        }
    }
}

}
$search = New-UDPage -Name “Search” -Icon search -Content { New-UDElement -Tag “div” -Attributes @{
style = @{
height = ‘25px’
}
}
New-UDRow -Columns {
New-UDColumn -Size 10 -SmallOffset 1 -Content {
New-UDRow -Columns {
New-UDColumn -Size 10 -Content {
New-UDTextbox -Id “txtSearch” -Label “Search” -Placeholder “Search for an object” -Icon search
}
New-UDColumn -Size 2 -Content {
New-UDButton -Id “btnSearch” -Text “Search” -Icon search -OnClick {
$Element = Get-UDElement -Id “txtSearch”
$Value = $Element.Attributes[“value”]

                    Set-UDElement -Id "results" -Content {
                        New-UDGrid -Title "Search Results for: $Value" -Headers @("Name", "More Info") -Properties @("Name", "MoreInfo") -Endpoint {
                            $Objects = Get-ADObject -Filter "Name -like '$Value' -or samAccountName -like '$Value'" -ResultSetSize 20 @Cache:ConnectionInfo -IncludeDeletedObjects
                            $Objects | ForEach-Object {
                                [PSCustomObject]@{
                                    Name = $_.Name
                                    MoreInfo = New-UDButton -Text "More Info" -OnClick {
                                        Invoke-UDRedirect -Url "/object/$($_.Name)"
                                    }
                                }
                            } | Out-UDGridData 
                        } 
                    }
                }
            }
        }
    }
} 
New-UDRow -Columns {
    New-UDColumn -SmallSize 10 -SmallOffset 1 {
        New-UDElement -Tag "div" -Id "results"
    }

}
}
$newuser = New-UDPage -Name “new user” -Icon Plus -Content {
New-UDRow -Columns {
New-UDColumn -Size 12 -Content {
New-UDInput -Title “Create User” -SubmitText “Create” -Content {
New-UDInputField -Name “FirstName” -Placeholder “First Name” -Type “textbox”
New-UDInputField -Name “LastName” -Placeholder “Last Name” -Type “textbox”
New-UDInputField -Name “UserName” -Placeholder “Account Name” -Type “textbox”
New-UDInputField -Name “Password” -Placeholder “Password” -Type “password”
} -Endpoint {
param(
$FirstName,
$LastName,
$UserName,
$Password
)

            try 
            {
                New-ADUser -Name $UserName -GivenName $FirstName -Surname $LastName @Cache:ConnectionInfo 
                Set-ADAccountPassword -Reset -NewPassword $Password -Identity $UserName @Cache:ConnectionInfo
                New-UDInputAction -RedirectUrl "/object/$UserName"
            }
            catch 
            {
                New-UDInputAction -Toast "Failed to add user. $_"
            }
        }
    }
}

}
$Udad = { New-PSDrive –Name AD –PSProvider ActiveDirectory $Cache:ConnectionInfo -Scope ‘Global’ –Root “//RootDSE/” function New-ADIcon {
param($ObjectClass, $Size)

$icon = 'question_circle'

if ($ObjectClass -eq 'user') {
    $icon = 'user'
}

if ($ObjectClass -eq 'computer') {
    $icon = 'desktop'
}

if ($ObjectClass -eq 'group') {
    $icon = 'users'
}

New-UDIcon -Icon $icon -Size $Size

}}
$EndpointInit = New-UDEndpointInitialization -Variable $Udad
$Endpoint = New-UDEndpoint -Endpoint {
try
{
$Objects = Get-ADObject -Filter { Name -like ‘*’} @Cache:ConnectionInfo
$Cache:Classes = $Objects | Group-Object -Property ObjectClass | Sort-Object -Property Count -Descending | Select-Object -First 10

    $Computers = $Objects | Where-Object ObjectClass -eq 'computer'

    $DomainControllers = Get-ADDomainController -Filter {Name -like '*'} @Cache:ConnectionInfo

    $Cache:Computers = @{
        Total                = ($Computers | Measure-Object).Count
        Disabled             = ($Computers | Where-Object Enabled -eq $false | Measure-Object).Count
        'Domain Controllers' = ($DomainControllers | Measure-Object).Count
    }.GetEnumerator()

    $Users = Get-ADUser -Filter { Name -like '*'} @Cache:ConnectionInfo -Properties *

    $Cache:Users = @{
        Total    = ($Users | Measure-Object).Count
        Disabled = ($Users | Where-Object Enabled -eq $false | Measure-Object).Count
    }.GetEnumerator()

    $Cache:Forest = Get-ADForest @Cache:ConnectionInfo
    $Cache:Domains = Get-ADDomain @Cache:ConnectionInfo
}
catch
{
    $Cache:Error = "Failed to load AD data. $_"
}
finally
{
    $Cache:Loading = $false

}
}-Schedule (New-UDEndpointSchedule -Every 30 -Second)
$pages = $newuser , $search , $object
$Dashboard = New-UDDashboard -Title “Cloudcom” -Pages ($pages )
Start-UDDashboard -Dashboard $Dashboard -Endpoint $Endpoint -Port 1001
}
version i used: Universal Dashboard V2.9.0

is your problem that you have nothing defined for that variable. I am thinking it is near impossible to fully help if you have no code to share other than telling you now that $Identity has nothing assigned to it, yet it is being called.

If you can use an AD module to get results in the powershell prompt, then just a case of converting that data to tables, or use it in forms or other component elements on the page

Not sure exactly on what you are asking other UD members to chip in here without any code provided.

Also just to follow forum rules if you could state the product and the version you are using to achieve this. Thanks

my apologies i will edit my post