-
Notifications
You must be signed in to change notification settings - Fork 7
local_user_delete.ps1
Corey Watson edited this page Dec 19, 2025
·
1 revision
Deletes a local user account and its associated profile directory.
This script deletes a local user account and its associated profile directory. Completely removes the user from the system including their files.
Deletes a local user account and its associated profile directory. Completely removes the user from the system including their files.
- Windows 10/11
- Admin privileges required
- PowerShell 5.1+
- Hardcoded values (username)
- WMI/CIM for profile removal
- UserToDelete : Username of the account to delete Set to "listusers" to only list current users
- Removes user profile via CIM (preferred method)
- Falls back to direct filesystem removal if CIM fails
- Lists users if no username provided or "listusers" specified
- If "listusers" mode: lists all local users and exits
- Validates user exists
- Removes user profile (CIM then filesystem fallback)
- Removes local user account
- Reports final status
- DESTRUCTIVE OPERATION - data cannot be recovered
- No secrets in logs
- Backup important data before running
- 0: Success
- 1: Failure
[ INPUT VALIDATION ]
--------------------------------------------------------------
User to Delete : tempuser
[ OPERATION ]
--------------------------------------------------------------
Found user: tempuser
Removing user profile...
Profile removed via CIM
Removing user account...
User account removed
[ RESULT ]
--------------------------------------------------------------
Status : Success
User : tempuser (deleted)
[ SCRIPT COMPLETED ]
--------------------------------------------------------------
- 2025-11-29 v1.0.0 Initial Style A implementation
- View Script Source
- Scripts - Back to script index