DRRAM
asked on
delete users
please How can I delete the list of users in active directory
ASKER
Please
I mean delete the users in different OU's and I want to process a large number of users from a text file, (e.g:via vbscript).
THX
I mean delete the users in different OU's and I want to process a large number of users from a text file, (e.g:via vbscript).
THX
Sure thing,
You probably want to do it with powershell
check out this thread, i have used the script before and it worked well
http://www.powershellcommunity.org/Forums/tabid/54/aft/3624/Default.aspx
It does require that you ahve powershell and the Quest AD extensions installed (Download here if you don't have them ... http://www.quest.com/powershell/activeroles-server.aspx)
Basiccally you are importing the csv list of users, then "foreach" of them, delete the user
I have modified it to only worry about the user account:
$_.userName refers to a column in the file "users.csv" titled userName, the -whatif asks if you are sure
You probably want to do it with powershell
check out this thread, i have used the script before and it worked well
http://www.powershellcommunity.org/Forums/tabid/54/aft/3624/Default.aspx
It does require that you ahve powershell and the Quest AD extensions installed (Download here if you don't have them ... http://www.quest.com/powershell/activeroles-server.aspx)
Basiccally you are importing the csv list of users, then "foreach" of them, delete the user
I have modified it to only worry about the user account:
$_.userName refers to a column in the file "users.csv" titled userName, the -whatif asks if you are sure
import-csv users.csv | foreach {
# get a reference to the user's account
$user = Get-QADUser $_.userName
# delete the user object
Remove-QADObject -identity $user -force -whatIf
}
ASKER
you have the code in the vbscript please
Sorry I don't, I use Powershell due to it's awesome AD integration that is made even better by the quest extensions
ASKER
the code is not working
in attachement
in attachement
import-csv users.csv | foreach {
# get a reference to the user's account
$user = Get-QADUser $_.userName
# delete the user object
Remove-QADObject -identity $user -force -whatIf
}
users.csv
Is there an error?
Did you install the quest extensions and launch their powertel environment ti run it?
Did you install the quest extensions and launch their powertel environment ti run it?
Try AD Manager Plus(trial version), it will serve the purpose.
Hi all,
DRRAM, Then you can delete the users group wise..
' VBScript to discover the members of a Group
strDomain = InputBox ("Enter Domain Name")
strGroup = InputBox ("Enter Group Name")
Set objExcel = CreateObject("Excel.Applic ation")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = "User Name"
Set objGroup = GetObject("WinNT://" & strDomain & "/" & strGroup)
Set strMembers = objGroup.Members
For Each strMember In strMembers
objExcel.Cells(intRow, 1).Value = strMember.Name
intRow = intRow + 1
Next
objExcel.Range("A1").Selec t
objExcel.Selection.Interio r.ColorInd ex = 19
objExcel.Selection.Font.Co lorIndex = 11
objExcel.Selection.Font.Bo ld = True
objExcel.Cells.EntireColum n.AutoFit
Set objSheet = objExcel.ActiveWorkbook.Wo rksheets(1 )
Set objRange = objExcel.Range("A1")
objRange.Sort objRange,1,,,,,,1
MsgBox "Done"
Thank you
Anil
DRRAM, Then you can delete the users group wise..
' VBScript to discover the members of a Group
strDomain = InputBox ("Enter Domain Name")
strGroup = InputBox ("Enter Group Name")
Set objExcel = CreateObject("Excel.Applic
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = "User Name"
Set objGroup = GetObject("WinNT://" & strDomain & "/" & strGroup)
Set strMembers = objGroup.Members
For Each strMember In strMembers
objExcel.Cells(intRow, 1).Value = strMember.Name
intRow = intRow + 1
Next
objExcel.Range("A1").Selec
objExcel.Selection.Interio
objExcel.Selection.Font.Co
objExcel.Selection.Font.Bo
objExcel.Cells.EntireColum
Set objSheet = objExcel.ActiveWorkbook.Wo
Set objRange = objExcel.Range("A1")
objRange.Sort objRange,1,,,,,,1
MsgBox "Done"
Thank you
Anil
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
thx very much " Scottyworld" please
To delete the pcs I can use the same code
how I can adapt this code
thx
To delete the pcs I can use the same code
how I can adapt this code
thx
It's pretty much the same change as the last code I gave you! A very simple change here...
On line 20,
ObjectCatagory=computer
ObjectClass=computer
That's it!
On line 20,
ObjectCatagory=computer
ObjectClass=computer
That's it!
ASKER
Thanks very much for the good support "Scottyworld"
No problem, happy to help out
Do you want to delete them all? do you want to delete all of the users that meet a certain criteria?
Elaborate a little please
Realizing that if you delete the user in active directory then that user can no longer log on/authenticate to the directory