none
Deleting Profile Folders - Access is Denied RRS feed

  • Question

  • Hi all! So here's my dilemma... I'm attempting to delete old profile folders from machines with a limited amount of remaining space on their C:\. This came about when we found a machine with 1GB of memory left and approximately 240 stale profiles. I'm wondering what the best way to accomplish this is. I've attempted to simply delete the folders from the machine but get an "access to the path $PATH is denied." I've verified that I'm the owner and that I'm running as an admin but to no success. Is this the way I even want to do this???

    (I realize that this can be done far easier on newer versions of PS but I'm the only one with an updated version, which I'm not sure if I'm even allowed to have...*Shhhhhh*.... So I've been trying to write for PS 2.0. Which could possibly be why I'm running into so many issues. The script is being written for a different group of people to make their lives easier.)

    Any Help would be greatly appreciated!

    Thursday, April 30, 2015 1:07 PM

Answers

All replies

    • Marked as answer by McCoid1017 Thursday, April 30, 2015 3:45 PM
    Thursday, April 30, 2015 1:11 PM
  • Try this step,

    Right click on My Computer-> Properties -> Click Advanced system settings " You might be Advanced Tab of System Properties" ->  Click settings on under User Profiles -> There you can select the user and Delete. 

    Hope this info helps...

    Regards,

    Joby

    Thursday, April 30, 2015 1:22 PM
  • I'm attempting to make a script so that they don't have to do this.... it takes too much time...
    Thursday, April 30, 2015 1:47 PM
  • I'm thinking I might have to do this... I was wanting to try and avoid this. I'll see what this can do though. Thanks!
    Thursday, April 30, 2015 1:50 PM
  • I'm thinking I might have to do this... I was wanting to try and avoid this. I'll see what this can do though. Thanks!

    I'm curious, why don't you want to use the tool?

    If you really want to script something, here's a starting point:

    http://stackoverflow.com/questions/3755741/delete-local-windows-profile-with-powershell


    Don't retire TechNet! - (Don't give up yet - 13,225+ strong and growing)

    Thursday, April 30, 2015 1:55 PM
  • eh well I work on a fairly monitored network so in order to download this I'll need to go to a commercial line, download it, and bring it onto the network. Which isn't really a bad thing but it's frowned upon if that makes sense. So instead I'd rather use the resources that are available to me. Or I guess in this case, makes something that will be useful to my techs with the resources that are available to them.
    Thursday, April 30, 2015 2:14 PM
  • $profiles=Get-WmiObject Win32_UserProfile -computer pc01 | Where{...filter...}
    $profiles | %{$_.Delete()}

    This works in all versions of PowerShell.  It works on all versions of Windows Vista and later.


    \_(ツ)_/


    • Edited by jrv Thursday, April 30, 2015 3:10 PM
    Thursday, April 30, 2015 3:10 PM
  • Awesome! That seems to get me a little farther but it won't delete them due to the directories not being empty. I'm not sure how to work a recurse into this. Also I seem to be getting an error that still says that I can't delete certain folders due to the fact that I have insufficient permissions even though I am the folder owner. Any ideas?
    Thursday, April 30, 2015 3:23 PM
  • What solution are you trying to use?  FOr local folders yo must run elevated as an admin.  The profile cannot be in use.  YOu must foilter out all system and protected profiles.

    Start by reading the documentation on any WMI class that is new.


    \_(ツ)_/

    Thursday, April 30, 2015 3:33 PM
  • I went ahead and just got delprof2... It was much easier lol. Thanks for the heads up!
    Thursday, April 30, 2015 3:45 PM
  • Cheers, you're very welcome. Glad it worked out.

    Don't retire TechNet! - (Don't give up yet - 13,225+ strong and growing)

    Thursday, April 30, 2015 4:14 PM