Anyone have a script to delete a specific local windows profile?

Posted by Jordan Weinstein on Server Fault See other posts from Server Fault or by Jordan Weinstein
Published on 2009-10-09T19:09:43Z Indexed on 2010/03/12 23:07 UTC
Read the original article Hit count: 175

I'm looking for Powershell (preferred) script, or .CMD or .VBS, to delete a specific user profile on a workstation (WinXP) or terminal server (2000, '03 or '08). I know all about the delprof utility... That only allows you delete based on a period of inactivity. I want a script to:

  • prompt admin for a username
  • delete that username's profile
    • and to delete the entire profile - registry hive too (not just the folder structure within Documents and Settings).
    • The same way it would if you went to My Computer> Properties> Advanced tab> User Profiles Settings> and deleted profiles from there.

Any ideas? All I can think of is doing an AD lookup to get the SID of the user specified, then using that to delete the correct registry hive too... something simpler would be nice though...

Basically, my HelpDesk used to be local administrators on our Citrix servers and a common fix for various issues was for them to delete a user's profile on the citrix server(s) and have that user log back in - voila, whatever issue they had was resolved. Going forward, in new Citrix environment, they will no longer be local admins on those boxes, but still need to be able to delete profiles (deleting the entire profile: folder and reg hive is key). thanks.

© Server Fault or respective owner

Related posts about powershell

Related posts about scripting