Creating a Batch File to Remove Home Directories
Novell Cool Solutions: Trench
By Alan Coutts
Digg This -
Posted: 17 Jul 2003
In a school/College environment, potentially hundreds of eDirectory accounts may have to be deleted at the end of each year. Here's a way to locate and remove the associated home directories. Other suggestions have been posted on the School Cool Solutions, but it does no harm to have another one.
This method relies on a particular NDS design, whereby you wish to delete all users from a particular OU. In my case, we group users by year and each year delete all year-6 pupils.
Before carrying any of this out, make sure you have a reliable backup.
- Download and install the "ODBC driver for eDirectory" from http://developer.novell.com/ndk/downloadaz.htm.
- Select the relevant context within the "Data Source Setup" section of the "ODBC Data Source Administrator" in the Windows Control Panel.
- Open Excel.
- Select "Data", "Get External Data", "New Database Query".
- Choose the Data Source created earlier.
- In the left hand column, expand "UserNDS" and double click on "Home Directory_Path".
- Click Next, Next, Next, Finish to return data to Excel.
- Move the data into column B or insert a new column as Column A.
- Delete the first row (Home Directory_Path).
- In cell A1, type "rmdir /s /q" and copy the command all the way down.
- Save the file as file type "Text (MS-DOS)" with a bat extension.
- Map a drive to the root of the volume where the home directories exist.
- Open a command window and copy the newly created batch file to the recently mapped drive.
- Run your new batch file and watch the home directories disappear.
Step 10 presumes you are using a WinNT workstation. If using Windows 98, the command is "deltree /y".
If you have questions for Alan, you can contact him at email@example.com
Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com