Link to home
Create AccountLog in
Avatar of DRRAM
DRRAM

asked on

delete users

please How can I delete the list of users in active directory
Avatar of Thorrsson
Thorrsson

Little more clarity required...
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
Avatar of DRRAM

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
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
 
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
}

Open in new window

Avatar of DRRAM

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
Avatar of DRRAM

ASKER

the code is not working
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
}

Open in new window

users.csv
Is there an error?
Did you install the quest extensions and launch their powertel environment ti run it?
Avatar of hirenvmajithiya
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.Application")

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").Select

objExcel.Selection.Interior.ColorIndex = 19

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

 

Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)

Set objRange = objExcel.Range("A1")

objRange.Sort objRange,1,,,,,,1

 

MsgBox "Done"

Thank you

Anil
ASKER CERTIFIED SOLUTION
Avatar of Scottyworld
Scottyworld
Flag of New Zealand image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of DRRAM

ASKER

thx very much " Scottyworld" please
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!
Avatar of DRRAM

ASKER

Thanks very much for the good support "Scottyworld"
No problem, happy to help out