N
Nik
Can anyone help us, we are a local college and every year we have to
take off a huge number of users form active directory. This is the
colleges first year on active directory and we are encoutering
problems with a script complied from MS technet... The script should
read a text file and delete that particular username's AD account and
their corresponding home directory. The script does delete the account
but the folder doesn't get deleted please help. the script is as
follows... any advice on how to fix this would be much appreciated.
Nik Patel
PS - please ignore the backup line and the create and copy folders
part this was incorporated so we could do a quick restore for students
if necessary. This is now on tape backup.
Dim FSO, TS, username, obj, home, objusr, backup
backup = "\\lsc-pcadmin3\data\"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set TS = FSO.OpenTextFile("users.txt")
on error resume next
do until TS.AtEndOfStream
username = TS.readline
'Get Home Directory
set objusr = GetObject("WinNT://lsc/"& username &", user")
home = objusr.HomeDirectory
'wscript.echo backup&username
'Create Destination Folder
FSO.CreateFolder(backup&username)
'Copy home directory
FSO.CopyFolder home , backup&username
'Delete home directory
FSO.DeleteFolder home , username
set objusr= nothing
'Delete User account
set obj = GetObject("WinNT://lsc")
obj.Delete "user" , username
set obj = nothing
TS.SkipLine
Loop
ts.close
WScript.Echo "Done"
take off a huge number of users form active directory. This is the
colleges first year on active directory and we are encoutering
problems with a script complied from MS technet... The script should
read a text file and delete that particular username's AD account and
their corresponding home directory. The script does delete the account
but the folder doesn't get deleted please help. the script is as
follows... any advice on how to fix this would be much appreciated.
Nik Patel
PS - please ignore the backup line and the create and copy folders
part this was incorporated so we could do a quick restore for students
if necessary. This is now on tape backup.
Dim FSO, TS, username, obj, home, objusr, backup
backup = "\\lsc-pcadmin3\data\"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set TS = FSO.OpenTextFile("users.txt")
on error resume next
do until TS.AtEndOfStream
username = TS.readline
'Get Home Directory
set objusr = GetObject("WinNT://lsc/"& username &", user")
home = objusr.HomeDirectory
'wscript.echo backup&username
'Create Destination Folder
FSO.CreateFolder(backup&username)
'Copy home directory
FSO.CopyFolder home , backup&username
'Delete home directory
FSO.DeleteFolder home , username
set objusr= nothing
'Delete User account
set obj = GetObject("WinNT://lsc")
obj.Delete "user" , username
set obj = nothing
TS.SkipLine
Loop
ts.close
WScript.Echo "Done"