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?