Link to home
Start Free TrialLog in
Avatar of saif1975
saif1975

asked on

Searching for multiple AD user accounts in different AD containers to expire multiple accounts

I have a list of user names from accross multiple OUs that need to be expired at a certain date/time. The problem is when I do a search in AD, I can only search for one user name and not for multiple accounts or from a csv file.

The names of users from accross the different OUs are available in excel and therefore can be exported in alphabetical list etc.
ASKER CERTIFIED SOLUTION
Avatar of Sushil Sonawane
Sushil Sonawane
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi, you can run DSQuery to help with your search.  This will give you a list of users and you can use the pipe command to have the information populate to a file.  http://technet.microsoft.com/en-us/library/cc725702%28v=ws.10%29.aspx
Avatar of Joseph Daly
Depending on wether you want to disable or expire the accounts use the quest powershell cmdlets below.

Disable
Import-CSV {filename}.csv | ForEach {get-qaduser $_.name | disable-qaduser}

Expire
Import-CSV {filename}.csv | ForEach {get-qaduser $_.name | set-qaduser -accountexpires 5/5/2012}
Avatar of saif1975
saif1975

ASKER

xxdcmast I ran the command but get the following error....


         Welcome to ActiveRoles Management Shell 1.5.1, a part of Quest ActiveRoles Server 6.7

 View ActiveRoles Server product page:     Get-QARSProductInfo
 Visit ActiveRoles Server community site:  Get-QARSCommunity
 List all cmdlets:                         Get-Command
 List only Management Shell cmdlets:       Get-QCommand
 View help:                                Get-Help
 View help about a cmdlet:                 Get-Help <cmdlet-name> or <cmdlet-name> -?
 View full output for a cmd:               <cmd> | Format-List

+ Import-CSV c:\temp\aleavers-100912.csv | ForEach {get-qaduser <<<<  $_.name | set-qaduser -accountexpires 10/09/2012}

    + CategoryInfo          : InvalidData: (:) [Get-QADUser], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlet
   s.GetUserCmdlet

Get-QADUser : Cannot validate argument on parameter 'Identity'. The argument is null or empty. Supply an argument that
is not null or empty and then try the command again.
At line:1 char:62
+ Import-CSV c:\temp\aleavers-100912.csv | ForEach {get-qaduser <<<<  $_.name | set-qaduser -accountexpires 10/09/2012}

    + CategoryInfo          : InvalidData: (:) [Get-QADUser], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlet
   s.GetUserCmdlet

Get-QADUser : Cannot validate argument on parameter 'Identity'. The argument is null or empty. Supply an argument that
is not null or empty and then try the command again.
At line:1 char:62
+ Import-CSV c:\temp\aleavers-100912.csv | ForEach {get-qaduser <<<<  $_.name | set-qaduser -accountexpires 10/09/2012}

    + CategoryInfo          : InvalidData: (:) [Get-QADUser], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlet
   s.GetUserCmdlet

Get-QADUser : Cannot validate argument on parameter 'Identity'. The argument is null or empty. Supply an argument that
is not null or empty and then try the command again.
At line:1 char:62
+ Import-CSV c:\temp\aleavers-100912.csv | ForEach {get-qaduser <<<<  $_.name | set-qaduser -accountexpires 10/09/2012}

    + CategoryInfo          : InvalidData: (:) [Get-QADUser], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlet
   s.GetUserCmdlet

Get-QADUser : Cannot validate argument on parameter 'Identity'. The argument is null or empty. Supply an argument that
is not null or empty and then try the command again.
At line:1 char:62
+ Import-CSV c:\temp\aleavers-100912.csv | ForEach {get-qaduser <<<<  $_.name | set-qaduser -accountexpires 10/09/2012}

    + CategoryInfo          : InvalidData: (:) [Get-QADUser], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlet
   s.GetUserCmdlet

Get-QADUser : Cannot validate argument on parameter 'Identity'. The argument is null or empty. Supply an argument that
is not null or empty and then try the command again.
At line:1 char:62
+ Import-CSV c:\temp\aleavers-100912.csv | ForEach {get-qaduser <<<<  $_.name | set-qaduser -accountexpires 10/09/2012}

    + CategoryInfo          : InvalidData: (:) [Get-QADUser], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlet
   s.GetUserCmdlet

Get-QADUser : Cannot validate argument on parameter 'Identity'. The argument is null or empty. Supply an argument that
is not null or empty and then try the command again.
At line:1 char:62
+ Import-CSV c:\temp\aleavers-100912.csv | ForEach {get-qaduser <<<<  $_.name | set-qaduser -accountexpires 10/09/2012}

    + CategoryInfo          : InvalidData: (:) [Get-QADUser], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlet
   s.GetUserCmdlet

Get-QADUser : Cannot validate argument on parameter 'Identity'. The argument is null or empty. Supply an argument that
is not null or empty and then try the command again.
At line:1 char:62
+ Import-CSV c:\temp\aleavers-100912.csv | ForEach {get-qaduser <<<<  $_.name | set-qaduser -accountexpires 10/09/2012}

    + CategoryInfo          : InvalidData: (:) [Get-QADUser], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlet
   s.GetUserCmdlet

Get-QADUser : Cannot validate argument on parameter 'Identity'. The argument is null or empty. Supply an argument that
is not null or empty and then try the command again.
At line:1 char:62
+ Import-CSV c:\temp\aleavers-100912.csv | ForEach {get-qaduser <<<<  $_.name | set-qaduser -accountexpires 10/09/2012}

    + CategoryInfo          : InvalidData: (:) [Get-QADUser], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlet
   s.GetUserCmdlet

Get-QADUser : Cannot validate argument on parameter 'Identity'. The argument is null or empty. Supply an argument that
is not null or empty and then try the command again.
At line:1 char:62
+ Import-CSV c:\temp\aleavers-100912.csv | ForEach {get-qaduser <<<<  $_.name | set-qaduser -accountexpires 10/09/2012}

    + CategoryInfo          : InvalidData: (:) [Get-QADUser], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlet
   s.GetUserCmdlet
What does your csv look like? It should have a single column called name
sushi84
AD Manager works!! Thanks for the tip
Great, it works!