Jump to content

Recommended Posts

Posted

Not sure if I'm already in holiday mode or not, but I can't think what the best way to do this is. I've copied all files to the users' OneDrive, but now I'd like to remove everything that is left in their home drive, apart from My Settings folder. I'll then send a simple text file to them all reminding them their files are on OneDrive (they have been told and emailed).

 

Any suggestions?

 

Thanks

Posted

I have a scan hot folder that I run this batch file on once a week to delete anything left in it

 

del x:\data\scans\*.* /s /q

 

Obviously yours might want to be like x:\data\users\%username%\*x* /s /q

 

I run mine on the server direct, obviously use at your own peril and test before deploying :)

Posted
You could use a combination of file screens and file management tasks in FSRM to clear out anything you no longer want in there and to prevent new unwanted files being added.
Posted

Thanks guys, I don't think it's quite what I'm looking for.

 

I can get a csv together that lists all student directory paths, ideally I'm after a script that will work it's way through this list, remove everything but the My Setting folder.

Posted

This Powershell script will delete all the files and folders in the directory, while retaining anything on the "excluded" list. It is also silent so it won't return an error if some files are read-only or in-use.

 

Remove-item C:\Random\Directory\* -exclude "MySpecialFolder", "MySecondSpecialFolder" -force -erroraction 'silentlycontinue'

Posted

Apologies, I just re-read your requirement and notice that you said you have paths in a CSV file. Something like this should work.

 

Get-Content 'D:\remove.csv' | ForEach-Object { $_.Trim() } | Remove-Item -exclude "MySpecialFolder", "MySecondSpecialFolder" -force -erroraction 'silentlycontinue'

  • Thanks 1
Posted

Thank you, I added -recurse as it was asking me each time

 

Get-Content 'D:\My.csv' | ForEach-Object { $_.Trim() } | Remove-Item -exclude "My Settings" -Recurse -force -erroraction 'silentlycontinue'

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...