Skip to main content

User Profile - Remove

Summary​

This script is destructive and should only be used after fully understanding the implications.​

This script deletes a user profile and removes the user account if it is local. It runs User Profile - Get Information after successful deletion.

Sample Run​

Example 1: Removes user profile and the local user from the machine​

Example1

Example 2: Removes user profile without removing the local user​

Example2

Example 3: Removes user profile based on SID. SID parameter can be used when UserName is not available. ​

Example3

Dependencies​

User Parameters​

NameExampleRequiredDescription
UsernametestuserPartiallyThe username of the user to remove. Can be in the format 'testuser', './testuser', or 'domain/testuser'.
PreserveUser1FalseIf set to 1, then the user account will not be deleted along with the profile.
SIDS-1-5-21-3623811015-3361044348-30300820-1013PartiallyThe SID of the user profile to remove. Preserve User can not be used with SID. This parameter can be used when can be used when UserName is not available.

Both UserName and SID can not be used together

Process​

See Remove-UserProfile for process information.

Output​

  • Script log
  • Local file on computer

Changelog​

2025-04-10​

  • Initial version of the document