Sometimes we ITPros do blunt and stupid things.   Sometimes we do them without thinking.

There and RIGHT and WRONG ways to delete USERProfile data on a workstation.

In the Pre Vista/7 days you could just go in to “Documents and Settings” and DELETE the old user data and all was good.  DONE!

Found something out in Vista and Windows 7.

*AHEM* – Don’t do that.  Or *IF* you do make sure you delete the reference of the user from the registry.  There is a spot in Windows 7 and Vista that says “User Profile for JOHNSMITH is HERE!”

If you do it the old way, just look for an entry under

HKEY_LOCAL_MACHINE\Software\Microsoft\Window NT\CurrentVersion\ProfileList

You’ll find a series of keys, under each one is an entry called “ProfileImagePath”. That will contain the path on the hard drive of where the User profile was.  If you do NOT delete that key you’ll find out the hard way that IF “JOHNSMITH” ever tries to log into that machine again?  He’ll keep getting logged in with a TEMP profile, which is … IRRITATING!

OR If you’re really “Lazy” (AHEM EFFICIENT) you can run a Script with Powershell like THIS to get rid of the offending key. 🙂

—– Profile Cleaner —–

$OLDUSERID=’John.Smith’
$REGPROF=’REGISTRY::HKLM\Software\Microsoft\Windows NT CurrentVersion\ProfileList’
$PROFLIST=GET-CHILDITEM $REGPROF
FOREACH ( $ITEM in $PROFLIST )

{

$userid=(get-itemproperty registry::$item).ProfileImagePath
if ($userid -like ‘*sean.kearney*’) { $userid; remove-item registry::$item -whatif }

}

—— Profile Cleaner —–

 

Ok that’s not such a lazy script but I just couldn’t RESIST using Powershell to do something 🙂

Cheers all and clean up your mess the right way

Sean
the Energized Tech

Advertisements