How to automatically remove inactive users from TruGrid
Automating the removal of inactive users is feasible for Domain Administrators, although it is not supported as a built-in policy within Active Directory. To simplify administrative overhead, this functionality can be implemented via automation using Active Directory and PowerShell scripting*
- Free up unused TruGrid licenses
- Ensure licenses are allocated only to active users
- Reduce manual administrative overhead, as Inactive users who remain in the TG-related AD group continue to consume licenses unnecessarily
- 1. Create and Save the script
Save your script as a .ps1 file in Notepad,
Example of PowerShell script:
$daysInactive = 30 - "Desired number of days user has been inactive"
$cutoffDate = (Get-Date).AddDays(-$daysInactive)
$groupName = "TG-USERS" - "Group that is used by TruGrid to sync users"
$users = Get-ADGroupMember $groupName | Where-Object { $_.objectClass -eq "user" }
foreach ($user in $users) {
$adUser = Get-ADUser $user.SamAccountName -Properties LastLogonDate
if ($adUser.LastLogonDate -lt $cutoffDate) {
Remove-ADGroupMember -Identity $groupName -Members $user -Confirm:$false
Write-Output "Removed $($user.SamAccountName)"
}
}
- Open Task Scheduler and create New Basic Taks

- Schedule time period when task should run Daily/Weekly/Monthly


- Action - set "Start Program"

- Program/Script: PowerShell.exe
- Argument: -ExecutionPolicy Bypass -File "C:\Scripts\RemoveInactiveUsersFromGroup.ps1"
- Start in: *-C:\Scripts*

- Once Task is created you could run it manually to test it out

Updated on: 27/03/2026
Thank you!
