Cheers Rob.
new to this scripting lark. That worked. 230 orphaned home folders. not too bad i guess.
Now to delete them manually!
Cheers Rob.
new to this scripting lark. That worked. 230 orphaned home folders. not too bad i guess.
Now to delete them manually!
We delete staff accounts the week after they leave (or in September if they leave over summer) but archive stuff to DVD.
Students get deleted at the end of the academic year (usually the last week in August) and again are archived to DVD.
The DVDs are stored until I get round to a clear out but for a min of 3 years in case exam boards want work etc.

Student accounts are deleted straight away after a backup of all documents.
Students entering our sixth form do not carry forward their Year 7 - 11 work. I create new accounts for them.
When staff leave they get a copy of all their work on CD / DVD - floppy disk for some! Their accounts are disabled and deleted after a backup and 6 months have passed.
Immediately staff leave we put them in a "leavers" folder and disable the account. We send out a memo a few weeks before they leave asking them to give files to successors etc. After a while and a backup we delete them. The exception is if they aren't really leaving - a couple of retired teachers do supply work, as does one of the office ladies.
Students, we're very often not told about (despite the introduction of a ticklist for HOYs to use) until they have been gone some time. I try to do a termly comparison of a list of users against a copy of the school roll. Year 11s/13s we get rid of if they don't come back in September. Keeping all accounts frozen until Christmas and disposing around then (which reminds me I've not done it this year yet!).
Aaaarrrrgh :-)
You've got this far with the script, just take a bit of time to get the rest of it done!
The key bit is here:
This is writing to the log file the good/bad folders so you just want to add something to delete the bad folders - it could be as simple as:Code:If strADPres = "Present" Then EchoAndLog Date & "," & Time & "," & strUNCStart & "\" & objSubFolder.Name & "," & "Folder/User is ok." Else EchoAndLog Date & "," & Time & "," & strUNCStart & "\" & objSubFolder.Name & "," & "Folder/User is bad. User Not Found!" End If
added after the "else" or (to be safer!) you can doCode:objfso.deletefolder(strUNCStart & "\" & objSubFolder.Name)
(make sure you have a folder called archive under the root of the home folders - eg if the server has d:\home\user1, d:\home\user2 etc then make a d:\home\archive)Code:objfso.movefolder strUNCStart & "\" & objSubFolder.Name strUNCStart & "\archive\"
This isn't perfect - the next time you run it, it will try and delete the archive folder - but I'm afraid I've not got time to work out how to specify a better location in that script. I'm sure that by the time you need it again your scripting will be good enough :-)
Hope i've done that right.Code:If strADPres = "Present" Then EchoAndLog Date & "," & Time & "," & strUNCStart & "\" & objSubFolder.Name & "," & "Folder/User is ok." Else EchoAndLog Date & "," & Time & "," & strUNCStart & "\" & objSubFolder.Name & "," & "Folder/User is bad. User Not Found!" objfso.movefolder strUNCStart & "\" & objSubFolder.Name strUNCStart & "\archive\" End If
I'm getting an expected end of statement here, (where the bold starts)
objfso.movefolder strUNCStart & "\" & objSubFolder.Name strUNCStart & "\archive\"
I'm guessing the one of the statements need to be in brackets???
sorry; shouldn't type stuff late at night when I can't test the code!
I missed a comma missing between the source and destination.Code:objfso.movefolder strUNCStart & "\" & objSubFolder.Name, strUNCStart & "\archive\"
You don't need brackets with movefolder; you do need them with deletefolder and I don't know why :-(
These are links to the MSDN item on deletefolder and movefolder - they have examples and docs.
stu1892 (8th January 2009)
Cheers Steve.
It worked up until the next orphaned folders beginning with 'B'!.
It looks like it's stopping with the archive folder. I'll need to move where the archive folder is. as it's checking the archive folder as a home directory.
Thanks to the technicians i inherited these users from, there's a load of users that still exist but their usernames have been changed and home folders left the way they were![]()
Last edited by stu1892; 8th January 2009 at 09:59 AM.
There are currently 1 users browsing this thread. (0 members and 1 guests)