locked
Retrieve a list of all users with homeMDB attribute containing a specific mailbox database RRS feed

  • Question

  • hi There,

    I am trying to retreive a list of users from AD with their "HomeMDB" attribute containing a specific mailbox database. I have exported out the list of users accounts from the users container into a CSV and using the following code: 

    PS C:\Users\xxxx\Desktop> import-csv "C:\Users\xxxx\Desktop\users.csv" | foreach-object{get-aduser -identity $_.user -SearchBase "dc=domain,dc=org" -SearchScope Subtree -Server servername.domain.org -Properties sAMAccountName,homeMTA,homeMDB} | select sAMAccountName,homeMTA,homeMDB | Export-csv C:\Users\xxxx\Desktop\exportfile.csv

    but it returns this error for each entity in the users CSV:

    Get-ADUser : Cannot validate argument on parameter 'Identity'. The argument is null or an element of the argument collection contains a null value.
    At line:1 char:90
    + ... user -identity $_.user -SearchBase "dc=domain,dc=org" -SearchScope Subtree -Serv ...
    +                    ~~~~~~~
        + CategoryInfo          : InvalidData: (:) [Get-ADUser], ParameterBindingValidationException
        + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.ActiveDirectory.Management.Commands.GetADUser


    Thursday, September 1, 2016 1:44 AM

Answers

  • Get-AdUser -Filter "HomeMDb -eq 'some homemdb'"

    That is all you have to do.


    \_(ツ)_/

    • Proposed as answer by Wendy Jiang Thursday, September 8, 2016 9:24 AM
    • Marked as answer by Wendy Jiang Tuesday, September 13, 2016 1:41 AM
    Thursday, September 1, 2016 2:16 AM
  • Jrv gives u answer. In your example, maybe the CSV is not a CSV with header, just bunch of usernames in column. Then, use -identity $_ .   Try it with get-content yourcsv.csv | %{get-aduser $_ -properties homemdb}

    • Proposed as answer by Wendy Jiang Thursday, September 8, 2016 9:24 AM
    • Marked as answer by Wendy Jiang Tuesday, September 13, 2016 1:41 AM
    Thursday, September 1, 2016 10:41 AM

All replies

  • I have also tried using different attributes like "displayname" to replace "identity" but received similar error
    Thursday, September 1, 2016 1:46 AM
  • Get-AdUser -Filter "HomeMDb -eq 'some homemdb'"

    That is all you have to do.


    \_(ツ)_/

    • Proposed as answer by Wendy Jiang Thursday, September 8, 2016 9:24 AM
    • Marked as answer by Wendy Jiang Tuesday, September 13, 2016 1:41 AM
    Thursday, September 1, 2016 2:16 AM
  • Jrv gives u answer. In your example, maybe the CSV is not a CSV with header, just bunch of usernames in column. Then, use -identity $_ .   Try it with get-content yourcsv.csv | %{get-aduser $_ -properties homemdb}

    • Proposed as answer by Wendy Jiang Thursday, September 8, 2016 9:24 AM
    • Marked as answer by Wendy Jiang Tuesday, September 13, 2016 1:41 AM
    Thursday, September 1, 2016 10:41 AM