Delete multiple accounts from AD wiht Powershell

MilesLogan
MilesLogan used Ask the Experts™
on
Hi EE

Does anyone have a script they can share that will delete AD accounts that I have on a text file ?
I want to enter the SamAccountname to the text file and the script delete those AD accounts .

Thank you !
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Remove the -WhatIf once you're ready to actually delete the users:

Get-Content .\users.txt | ForEach-Object {
    Remove-ADUser $_ -Confirm:$false -WhatIf
}

Open in new window

Author

Commented:
I was close lol !

I was missing this ... -Confirm:$false

thank you

Commented:
Glad I could help.  Take care
giphy-facebook_s.jpg

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial