Product: PowerShell Universal
Version: 5.1.2
In my dashboard I use roles to give an access to an element in my dashboard only for admins and helpdesk users
I take advantage of this example:
I logged in ad admin, but not see the button.
This is my code based on the example above:
#Check if the user has access to create provider, if so show him an option for user selection.
if ($Roles -contains $Role_CreateProvider) {
$Page:UserName = $User
$Cache:FormWorkerList = (Get-Workers -SQLServerName $SQLServerName | Sort-Object Username)
New-UDAutocomplete -Id 'atcWorkerUnlock' -Options @(
$Cache:FormWorkerList | ForEach-Object { New-UDAutocompleteOption -Name $_.Username -Value $_.WORKER_ID }
) -Label 'Select Username' -OnChange {
$Page:UserName = ((Get-UDElement -Id 'atcWorkerUnlock').Options | ForEach-Object { if ($_.Value -eq (Get-UDElement -Id 'atcWorkerUnlock').Value) { $_.Name } })
Sync-UDElement -Id 'eleGetProviders'
}
}
else { $Page:UserName = $User } # If user does not have permissions, use the current logged on username.
$Role_CreateProvider = @('Administrator', 'Helpdesk')