Last week, one of my administrators was complaining at how involved it was to remove a profile on a remote user’s computer. A little over two years ago, I wrote Delete Inactive Profiles, as a substitute for DelProf for post Windows XP OS. That script is an advanced function, and was designed to remove stale profiles from shared, common computers running periodically as a task, or with SCCM. But this script really isn’t a good way to selectively delete remove user profiles.
Sometimes “blowing away” the user’s profile is a quick way to fix quirky problems from corrupted settings. Delete-UserProfiles.ps1 was written based on the code of the previous script. It prompts you for the FQDN of the remote computer, then lists the user profiles on the remote computer with inactivity days in Out-Gridview, where you can choose which to delete. The user name is resolved using the [adsi] accelerator and the SID LDAP binding syntax. You are reminded that you need to be an administrator on the remote computer if you aren’t an administrator on the machine you are running the script from. The profile is deleted using the delete function of WMI win32_userprofile.
No profiles are deleted without a confirmation.