Solved

Need script to clear home drive AD attributes from a list of users

Posted on 2008-06-14
2
471 Views
Last Modified: 2010-04-21
I have a list of user accounts (username only, one user per line) in a text file, and I need a way to remove the home drive attributes from these users active directory accounts. I'm looking for a vbscript that will read this text file, and for each user search a given OU (and all OUs underneath that OU) and if it finds the user, it removes the home drive attributes from their accounts.

If possible, I'd also like it to output to a file containg each account that it processed and it's location in AD, as well as its success or failure.

Any help would be appreciated. Thanks!

0
Comment
Question by:TWCMIL
[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 Comments
 
LVL 7

Accepted Solution

by:
fhmc earned 500 total points
ID: 21786918
I just scrambled this idea together and only tested it briefly....  AND it's not a VB answer...  that said

from a cmd prompt (this can be customized to run via a logon script, another bat file, etc.)  e.g. this approach wouldn't be too hard to customize for your environment:

create a batch file... call it homedirmod.bat for now
:: log username
echo %1 >> log.txt
:: set user's home dir to nul
net user /domain %1 /homedir:
::  log user's homedir path...  no data should be present to the right of the Home Directory reference
net user /domain %1 |find "Home" >> log.txt
::  find and log user's OU container
dsquery user -samid %1  >> log.txt

:end


now, call that batch file in the following manner:

for /f %1 in (yourtextfilenamethatcontainsuseraccounts) do call homedirmod.bat %1



your logfile should resemble something like:

username
Home Directory
OU
username
Home Directory
OU
etc.
0
 
LVL 1

Author Closing Comment

by:TWCMIL
ID: 31467251
This works perfectly for me. No problem that it wasn't vbscript, I had assumed that it couldn't be done via batch file and I was wrong. One small correction I had to make was in the command to call the batch file:

for /f %i in (yourtextfilenamethatcontainsuseraccounts) do call homedirmod.bat %i

Had to change the %1 to %i, then it worked properly. Thanks again for your help.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

This article runs through the process of deploying a single EXE application selectively to a group of user.
A hard and fast method for reducing Active Directory Administrators members.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

737 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