Local Group Access
Overview
Rather than creating a temporary local account, this pattern grants JIT access by adding the requesting user’s existing domain account to a local group (e.g. Remote Desktop Users or Administrators) on a remote Windows server. At checkin, the user is removed from the group.
This pattern is preferred when:
- Users already have domain accounts and just need temporary server access
- You want to avoid creating local accounts on servers
- Audit trails should reference the user’s real identity
Before You Begin
- The broker is running and connected (see Getting Started)
- WinRM is enabled on the target Windows server
- The broker service account has local administrator rights on the target server (to modify local group membership remotely)
Checkout Routine
Full script: Windows/permissions/local-admin-remote-server/checkout.ps1
Environment variables:
| Variable | Notes |
|---|---|
user | Injected — requesting user’s UPN (e.g. jdoe@contoso.com) |
target | Target server hostname or FQDN |
group | Local group name (e.g. Remote Desktop Users, Administrators) |
Add domain user to local group via WinRM:
$UserUPN = $env:user
$TargetComputer = $env:target
$TargetGroup = $env:group
Invoke-Command -ComputerName $TargetComputer -ScriptBlock {
param($RemoteUser, $GroupName)
Add-LocalGroupMember -Group $GroupName -Member $RemoteUser -ErrorAction Stop
Write-Output "User $RemoteUser added to group $GroupName"
} -ArgumentList $UserUPN, $TargetGroupCheckin Routine
Full script: Windows/permissions/local-admin-remote-server/checkin.ps1
$UserUPN = $env:user
$TargetComputer = $env:target
$TargetGroup = $env:group
Invoke-Command -ComputerName $TargetComputer -ScriptBlock {
param($RemoteUser, $GroupName)
Remove-LocalGroupMember -Group $GroupName -Member $RemoteUser -ErrorAction Stop
Write-Output "User $RemoteUser removed from group $GroupName"
} -ArgumentList $UserUPN, $TargetGroupAdd-LocalGroupMember and Remove-LocalGroupMember accept UPN format (user@domain.com) directly when the server is domain-joined. No pre-existing local account is created or required.
Multi-Server Access
To grant access to multiple servers from a single profile, set target as a variable on the resource rather than the permission. Each registered Windows server resource can carry its own target value, and the same checkout/checkin routines apply to all of them.
Configure in Britive
Create a permission
Go to Resource Manager → Resource Type Permissions → New Permission. Set Language to PowerShell.
Paste checkout.ps1 and checkin.ps1 into the Checkout and Checkin fields.
Declare variables:
| Variable | System defined | Notes |
|---|---|---|
user | Yes | Injected automatically — the requesting user’s UPN |
target | No | Set per resource or on the permission |
group | No | e.g. Remote Desktop Users or Administrators |
Create a profile
Go to Resource Manager → Profiles → New Profile. Set an expiration (e.g. 2h). Under Associations, select the resource label(s) covering the target Windows servers. Under Permissions, add the permission above.
Add a policy
Under Policies, assign members (users or tags) and configure approval conditions as needed.
Verify
Check out the profile
Navigate to My Access → find the profile → Check Out.
Confirm group membership on the target server
Invoke-Command -ComputerName "prod-win-01" -ScriptBlock {
Get-LocalGroupMember -Group "Remote Desktop Users"
}
# The requesting user's UPN should appear in the outputConnect via RDP
Connect using the user’s existing domain credentials — the server now allows RDP for this user.
Check in
Return to My Access → Check In.
Confirm membership is removed
Invoke-Command -ComputerName "prod-win-01" -ScriptBlock {
Get-LocalGroupMember -Group "Remote Desktop Users"
}
# The user should no longer appearTroubleshoot
| Symptom | Cause | Fix |
|---|---|---|
Invoke-Command access denied | Broker gMSA lacks WinRM access to target | Add gMSA to target’s Remote Management Users group or local Administrators |
Add-LocalGroupMember fails — member not found | UPN format not recognized on non-domain server | Ensure the target server is domain-joined and the user account exists in AD |
| User still has RDP access after checkin | Checkin routine failed silently | Check broker logs; run Remove-LocalGroupMember manually to recover |
target variable empty | Not set on the resource or permission | Add target as a variable on the resource parameter or permission configuration |