?
Solved

Script to delete files from user profile

Posted on 2013-06-05
5
Medium Priority
?
1,460 Views
Last Modified: 2013-06-19
Hello,

Network:

Windows Server 2008 R2
Windows 7 Pro x64
Roaming Profiles

Problem:

I've got a user profile that contains files which have a path and filename that are to long to be handled by the operating system. So I can't delete the files. I've got GPO's running that should clean up these files during logoff. Logging off takes very long time, and then i get an error message that the profile could not sync properly. That's because the policy is unable to delete the files.0

Can I delete the files in question somehow? With a powershell script maybe?
0
Comment
Question by:SvenIA
  • 2
  • 2
5 Comments
 
LVL 10

Expert Comment

by:Sam Simon Nasser
ID: 39221394
can you explain this:
have a path and filename that are to long to be handled by the operating system

so the user desktop for example is set to c:\users\userX\desktop and not X:\Server\UserX\Desktop
0
 
LVL 7

Author Comment

by:SvenIA
ID: 39221409
Sure i can;

Profile
That folder contains files which have names that are to long. They cannot be deleted.

The policy that is configured to delete these temp files on logoff, cannot delete these files either. That's why profile sync times out when logging off.

The profile is way to large. So I want to cleanup.
0
 
LVL 10

Assisted Solution

by:Sam Simon Nasser
Sam Simon Nasser earned 500 total points
ID: 39221578
i once did it on windows XP, but in different way:
i created  roaming profile, that sync ONLY My Documents, Favorites and Desktop (these 3 are backed on the server), other items will be stored locally.

give it a try, in your way, let the profile sync everything EXCEPT the appData folder (only appData will be stored locally, other folders are on the roaming profile on the server.)
0
 
LVL 10

Accepted Solution

by:
CSI-Windows_com earned 500 total points
ID: 39224135
Try the rmdir (rd) command which will remove files as well as long as you give it all the below parameters  (it also continues when it hits files that cannot be removed - hand for temp clean up):

rmdir "d:\profiles\heinejas.v2\appdata\local\microsoft\windows\temporary internet files" /s /q

Another possible work around:

subst r: d:\profiles\heinejas.v2\appdata\local\microsoft\windows

rmdir "r:\temporary internet files" /s /q

And some custom powershell code for long paths handling:

http://huddledmasses.org/long-path-module-experimental-io/
0
 
LVL 7

Author Closing Comment

by:SvenIA
ID: 39259849
I created a connection directly to the users profile folder. In that way the path is shorter. Then i could delete the files.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
Assume you have an outside contractor who comes in seasonally or once a week to do some work in your office, but you only want to give him access to the programs and files he needs and keep all other documents and programs private. Can you do this o…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.
Suggested Courses

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question