Hello,
I'm trying to write a vbscript which deletes a user from the Active directory and all his data.
Here's the info:
Profiledata location: \\server\profile$\accountname
TSprofiledata location: \\server\tsprofile$\accountnameUserdata location: \\server\userdata$\accountname
domainname: newyork.america.com
The users are most often in several subOU's.
I wan't the script to prompt for the accountlogonname. Then I wan't to fill in the loginname and the the script must delete the AD useraccount and the directory's above.
I already tried the thing below but it doesn't work. I have to fill in the userdisplay name as in AD. I also have to fill in AD ou's which I most of the time don't know. I have to fill in to many things. Also it only deletes the first directory and not the other two.
I'm just an admin and not a programmer so please help me with some dummie vbscript.
Thanks for your help.
On Error Resume Next
Dim subou
Dim mainou
Dim Inputname
Dim loginname
subou = InputBox("enter the subou ")
mainou = InputBox("enter the mainou")
Inputname = InputBox("Enter the username")
loginname = InputBox("Enter the loginname")
set objOU = GetObject("LDAP://ou="& subou & ",ou=" & mainou &",dc=newyork,dc=america,dc=com")
objOU.Delete "user", "cn= " & loginname
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFolder("\\grnnt025\profiles$\" & loginname)
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFolder("\\grnnt025\TSprofiles$\" & loginname)
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFolder("\\grnnt025\userdata$\" & loginname)
I'm trying to write a vbscript which deletes a user from the Active directory and all his data.
Here's the info:
Profiledata location: \\server\profile$\accountname
TSprofiledata location: \\server\tsprofile$\accountnameUserdata location: \\server\userdata$\accountname
domainname: newyork.america.com
The users are most often in several subOU's.
I wan't the script to prompt for the accountlogonname. Then I wan't to fill in the loginname and the the script must delete the AD useraccount and the directory's above.
I already tried the thing below but it doesn't work. I have to fill in the userdisplay name as in AD. I also have to fill in AD ou's which I most of the time don't know. I have to fill in to many things. Also it only deletes the first directory and not the other two.
I'm just an admin and not a programmer so please help me with some dummie vbscript.
Thanks for your help.
On Error Resume Next
Dim subou
Dim mainou
Dim Inputname
Dim loginname
subou = InputBox("enter the subou ")
mainou = InputBox("enter the mainou")
Inputname = InputBox("Enter the username")
loginname = InputBox("Enter the loginname")
set objOU = GetObject("LDAP://ou="& subou & ",ou=" & mainou &",dc=newyork,dc=america,dc=com")
objOU.Delete "user", "cn= " & loginname
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFolder("\\grnnt025\profiles$\" & loginname)
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFolder("\\grnnt025\TSprofiles$\" & loginname)
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFolder("\\grnnt025\userdata$\" & loginname)