I had a customer who wanted to give users admin access on personal AVDs, but instead of directly using their regular account, each user had an "LA" (local admin) account they would use when they needed that level of access. In this case, the user account was FirstInitialLastName@domain.com and the admin account was FirstInitalLastName.LA@domain.com. This made it easy to adjust the built in script for adding assigned users as admins. Here is the updated script I created:
#description: Adds the admin account of the user assigned to a personal desktop to the local Administrators group on the session host VM. Use only with personal host pools.
#execution mode: Combined
#tags: Nerdio
<#
Notes:
This script adds the admin account (in the format firstinitial.lastname@domain.com) of the user assigned to the personal desktop to the local admin group.
#>
if ($DesktopUser) {
# Extract the first initial and last name from the user account
$userParts = $DesktopUser -split '@'
$userName = $userParts[0]
$domain = $userParts[1]
# Transform the user account format to the admin account format
$adminAccount = $userName + '.la@' + $domain
# Add the admin account to the local Administrators group
Add-LocalGroupMember -Group "Administrators" -Member $adminAccount
} else {
Write-Error -Message 'ERROR: No Desktop User Specified. This VM may not be a personal Desktop.'
exit
}
Comments (0 comments)