Browse and extract files from App-V packages located on local disk, smb file shares and web servers.

Profile Trasher

Profile Trasher is a Powershell script that deletes cached Windows 2016 Local User Profiles at logoff, ensuring that users get a brand new User Profile at every logon.

Profile Trasher is intended for use on Citrix XenApp Servers running Windows 2016 Server.

A Scheduled Task is required. The task is triggered by logoff events. When a logoff event is triggered, Profile Trasher will enumerate all non-local (Domain Users only) user profiles and delete them.


# Chawn Limited - Citrix Partner - Silver Solution Advisor
# No Liability accepted - Use at your own risk
# Ensure that you validate usage of this script in a pre-prod environment
# Create a task that is triggered by System Winlogon Log Event ID 7002
# Powershell.exe -ExecutionPolicy ByPass -NoProfile -File <PathToFile>\TrasherV1.ps1

# adjust the script sleep time to allow for the user to log off fully
Start-Sleep -Seconds 3

# Define Domain Users that you wish to exclude from profile deletion - case sensitive

$SIDs=gwmi -Query "Select * from win32_userprofile where Loaded='False'" | select SID


foreach ($SID in $SIDS) {
$objSID = New-Object System.Security.Principal.SecurityIdentifier($SID.SID)
$objUser = $objSID.Translate( [System.Security.Principal.NTAccount])

if ($excludeUsers.Contains($objUser.value)) {write-eventlog -logname Application -source Winlogon -eventID 888 -entrytype Information -message "Profile retained for User: $objUser with SID: $objSID"

# Filter out the Local (non-Domain Users) from the Array - We don't want to delete Local profiles inc. Administrator, System and Service users
If ($objuser.value.Split("\")[0] -ne $env:Computername) {
try {
# Delete the User Profile
gwmi win32_userprofile | where SID -eq $SID.SID | Remove-WmiObject

# Additional actions - below action is not required - just an example
# remove-item "hklm:\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\$objSID" -recurse

# Write to the event log for auditting
write-eventlog -logname Application -source Winlogon -eventID 777 -entrytype Information -message "Profile deleted for User: $objUser with SID: $objSID"
catch{ "Error encountered" }



Copy the downloaded script to a local folder (C:\Windows) on you Master XenApp virtual machine.

Create a Scheduled Task with the following properties:


Action: Start a Program

Program: Powershell.exe

Argument: -ExecutionPolicy ByPass -NoProfile -File C:\Windows\TrasherV1.ps1