Skip to content

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:

VariableNotes
userInjected — requesting user’s UPN (e.g. jdoe@contoso.com)
targetTarget server hostname or FQDN
groupLocal 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, $TargetGroup

Checkin 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, $TargetGroup

Add-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:

VariableSystem definedNotes
userYesInjected automatically — the requesting user’s UPN
targetNoSet per resource or on the permission
groupNoe.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 output

Connect via RDP

Connect using the user’s existing domain credentials — the server now allows RDP for this user.

Check in

Return to My AccessCheck In.

Confirm membership is removed

Invoke-Command -ComputerName "prod-win-01" -ScriptBlock {
    Get-LocalGroupMember -Group "Remote Desktop Users"
}
# The user should no longer appear

Troubleshoot

SymptomCauseFix
Invoke-Command access deniedBroker gMSA lacks WinRM access to targetAdd gMSA to target’s Remote Management Users group or local Administrators
Add-LocalGroupMember fails — member not foundUPN format not recognized on non-domain serverEnsure the target server is domain-joined and the user account exists in AD
User still has RDP access after checkinCheckin routine failed silentlyCheck broker logs; run Remove-LocalGroupMember manually to recover
target variable emptyNot set on the resource or permissionAdd target as a variable on the resource parameter or permission configuration
Last updated on