Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

need some help to remove users from AD that are in a csv or text file


Recommended Posts

Posted (edited)

I am trying to remove a bunch of users that I have extracted from AD and exported to a csv is formated this way:

SamAccountName

user1

user2

user3

I am trying to run the following in a ps script:

Import-Csv .\delete1.csv | foreach-object {

remove-aduser -identity $_.SamAccountName -confirm:$false }

 

i then get the following error:

Remove-ADUser : Cannot validate argument on parameter 'Identity'. The argument

is null. Supply a non-null argument and try the command again.

At C:\remove\deleteuser.ps1:2 char:24

+ remove-aduser -identity <<<< $_.SamAccountName -confirm:$false }

+ CategoryInfo : InvalidData: (:) [Remove-ADUser], ParameterBindi

ngValidationException

+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Activ

eDirectory.Management.Commands.RemoveADUser

 

Any ideas on what I am missing?

Edited by roblobster

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...