?
Solved

Script to delete files from user profile

Posted on 2013-06-05
5
Medium Priority
?
1,417 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

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

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 article explains how to install and use the NTBackup utility that comes with Windows Server.
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Suggested Courses

764 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