our code:
$Schedule = New-UDEndpointSchedule -Every 2 -Minute
$Endpoint = New-UDEndpoint -Schedule $schedule -Endpoint {
$deleted_users = Get-Adobject -SearchBase "CN=Deleted Objects,DC=is,DC=edu,DC=vn" -Filter 'IsDeleted -eq $true -and objectClass -eq "user"' -IncludeDeletedObjects
$Cache:deleted_users = $deleted_users
}
$homepage = New-UDPage -Name “Home” -DefaultHomePage -Content {
New-UDCard -Content {
"Thi is test"
}
}
$page1 = New-UDPage -Name DeletedUsers -Url /DeletedUsers -Content {
New-UDTabs -Tabs {
New-UDTab -Text 'Item One' -Content {
$columns =@(
New-UDTableColumn -Property Name -Title Name
New-UDTableColumn -Property DistinguishedName -Title "Distinguished Name"
New-UDTableColumn -Property DistinguishedName -Title Restore -Render {
$item = $Body | ConvertFrom-Json
New-UDButton -Id "btn-$($item.DistinguishedName)" -Text "Restore" -OnClick {
try
{
Restore-ADObject -Identity $($item.DistinguishedName)
{
Show-UDToast -Message "We are performing restoring user" -Duration 5000
}
}
catch
{
$output= $($_.exception.message)
}
if($?)
{
Show-UDToast -Message "Restore user $($item.DistinguishedName) successfully" -Duration 5000
}
else
{
$output = Get-UAJobOutput -JobId $job.id | Select-Object -ExpandProperty Message
Show-UDToast -Message "fail to restore user $($output)" -Duration 5000
}
Sync-UDElement -Id 'domain-details-tbl'
}
}
)
New-UDTable -Id 'domain-details-tbl' -Data $Cache:deleted_users -Columns $columns -Sort -Search
}
New-UDTab -Text 'Item Two' -Content { New-UDTypography -Text 'Item Two' -Variant 'h2' }
New-UDTab -Text 'Item Three' -Content { New-UDTypography -Text 'Item Three' -Variant 'h2' }
}
}
$Cache:Loading = $true
New-UDDashboard -Title “Active Directory” -Pages @($homepage, $page1)