Solved

Script to delete files from user profile

Posted on 2013-06-05
5
1,300 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 250 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 250 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

Why spend so long doing email signature updates?

Do you spend loads of your time carrying out email signature updates? Not very interesting are they? Don’t let signature updates get you down. Let Exclaimer Cloud - Signatures for Office 365 make managing email signatures a breeze.

Question has a verified solution.

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

Article by: Lee
Windows 7 Ultimate and Enterprise (and 2008 R2) introduced a new feature you may not be aware of - Boot from VHD.   Boot from VHD (or what Microsoft refers to asNative Boot allows you to install Windows to a VHD (Virtual Hard Disk) file that is t…
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
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…
This Micro Tutorial will give you a basic overview of Windows Live Photo Gallery and show you various editing filters and touches to photos you can apply. This will be demonstrated using Windows Live Photo Gallery on Windows 7 operating system.

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now