Windows Vista Forums

Retrieving all HomeMDB props from AD
  1. #1


    Jonathan Kalmes Guest

    Retrieving all HomeMDB props from AD

    Hey all,

    I've got another issue I need rescuing from... I keep approaching this
    from different angles and banging my head against a wall every time.



    I need to retrieve a list of users on an Exchange 2003 store. I know
    there's an AD property for this called "homeMDB". Unfortunately, it's
    one I can't get to easily using get-QADUser or anything else I've tried.

    Anyone got an idea how I can retrieve a list of all users on one store?
    Or, even better, all users that have a mailbox and what store they're on?

    --Jonathan

      My System SpecsSystem Spec

  2. #2


    Bob Butler Guest

    Re: Retrieving all HomeMDB props from AD

    "Jonathan Kalmes" <smthng@xxxxxx> wrote in message
    news:OwN43xvIIHA.1316@xxxxxx

    > Hey all,
    >
    > I've got another issue I need rescuing from... I keep approaching this
    > from different angles and banging my head against a wall every time.
    >
    > I need to retrieve a list of users on an Exchange 2003 store. I know
    > there's an AD property for this called "homeMDB". Unfortunately, it's one
    > I can't get to easily using get-QADUser or anything else I've tried.
    >
    > Anyone got an idea how I can retrieve a list of all users on one store?
    > Or, even better, all users that have a mailbox and what store they're on?
    I've had success with code like this

    $dpath=LDAP://<whatever>
    $filter="(homeMDB=*)"
    $root=new-object System.DirectoryServices.DirectoryEntry($dpath)
    $srch=new-object System.DirectoryServices.DirectorySearcher
    $srch.SearchRoot=$root
    $srch.Filter=$filter
    $x=$srch.PropertiesToLoad.add("cn")
    $x=$srch.PropertiesToLoad.add("homeMDB")
    $srch.SearchScope=[System.DirectoryServices.SearchScope]::Subtree
    $srchRes=$srch.FindAll()
    $x=$Srch.Dispose()
    if ($srchRes -ne $null) {
    foreach ($entry in $srchres) {
    write-host $entry.properties["cn"][0].ToString()
    $entry.properties["homemdb"][0].ToString()
    }
    }


      My System SpecsSystem Spec

  3. #3


    Brandon Shell [MVP] Guest

    Re: Retrieving all HomeMDB props from AD

    Try this

    $ds = new-Object System.DirectoryServices.DirectorySearcher([ADSI]"","(&(objectcategory=user)(homeMDB=*))",@('sAMAccountName','homeMDB'))
    $ds.pagesize = 1000
    $ds.findall() | format-table @{l="sAMAccountName";e={$_.properties.samaccountname}},@{l="homeMDB";e={$_.properties.homemdb}}
    -auto

    Brandon Shell
    ---------------
    Blog: http://www.bsonposh.com/
    PSH Scripts Project: www.codeplex.com/psobject

    JK> Hey all,
    JK>
    JK> I've got another issue I need rescuing from... I keep approaching
    JK> this from different angles and banging my head against a wall every
    JK> time.
    JK>
    JK> I need to retrieve a list of users on an Exchange 2003 store. I
    JK> know there's an AD property for this called "homeMDB".
    JK> Unfortunately, it's one I can't get to easily using get-QADUser or
    JK> anything else I've tried.
    JK>
    JK> Anyone got an idea how I can retrieve a list of all users on one
    JK> store?
    JK> Or, even better, all users that have a mailbox and what store
    JK> they're on?
    JK> --Jonathan
    JK>



      My System SpecsSystem Spec

  4. #4


    Steven Peck Guest

    RE: Retrieving all HomeMDB props from AD

    Not quite the approach you are looking for, but perhaps of use as well.

    # Get date for file name
    $day = Get-Date -UFormat "%Y%m%d"

    # Gets data through WMI from specified Exchange mailbox servers
    $computers = "server01","server02"
    foreach ($computer in $computers) {
    Get-Wmiobject -namespace root\MicrosoftExchangeV2 -class Exchange_Mailbox
    -computer $computer | sort-object -desc MailboxDisplayName | select-object
    MailboxDisplayName,StorageGroupName,StoreName,Size,DateDiscoveredAbsentInDS |
    Export-Csv -Path $computer-$day.csv
    }

    "Jonathan Kalmes" wrote:

    > Hey all,
    >
    > I've got another issue I need rescuing from... I keep approaching this
    > from different angles and banging my head against a wall every time.
    >
    > I need to retrieve a list of users on an Exchange 2003 store. I know
    > there's an AD property for this called "homeMDB". Unfortunately, it's
    > one I can't get to easily using get-QADUser or anything else I've tried.
    >
    > Anyone got an idea how I can retrieve a list of all users on one store?
    > Or, even better, all users that have a mailbox and what store they're on?
    >
    > --Jonathan
    >

      My System SpecsSystem Spec

  5. #5


    Kirk Munro Guest

    Re: Retrieving all HomeMDB props from AD

    Hi Jonathan,

    Here's how to do this using QAD cmdlets:

    Get-QADUser -LdapFilter "(mail=*)" -SizeLimit 10 -IncludeAllProperties |
    Sort-Object -Property homemdb,Name | Format-Table -GroupBy HomeMDB

    This will retrieve the first 10 mail-enabled users, sort them by homeMDB and
    then by name, and then output them in a grouped tabular format so that you
    can see the mail-enabled users per store. Once you test that and tweak it
    to your liking you can either increase the -SizeLimit (up to 1000) or if you
    want more than 1000 objects, set -SizeLimit to 0.

    FYI, the reason you may have been struggling with homemdb is because it
    isn't one of the default properties returned by Get-QADUser.
    The -IncludeAllProperties parameter tells the cmdlet to retrieve everything
    it can. And the ldap filter of (mail=*) tells it to only retrieve users
    that have an email address set (i.e. only users that are mail enabled).

    A little simpler than using ADSI, IMO.

    --
    Kirk Munro
    Poshoholic
    http://poshoholic.com


    "Jonathan Kalmes" <smthng@xxxxxx> wrote in message
    news:OwN43xvIIHA.1316@xxxxxx

    > Hey all,
    >
    > I've got another issue I need rescuing from... I keep approaching this
    > from different angles and banging my head against a wall every time.
    >
    > I need to retrieve a list of users on an Exchange 2003 store. I know
    > there's an AD property for this called "homeMDB". Unfortunately, it's one
    > I can't get to easily using get-QADUser or anything else I've tried.
    >
    > Anyone got an idea how I can retrieve a list of all users on one store?
    > Or, even better, all users that have a mailbox and what store they're on?
    >
    > --Jonathan


      My System SpecsSystem Spec

Retrieving all HomeMDB props from AD problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieving old files Shane_Shane Vista installation & setup 1 08 Mar 2008
retrieving mail Mara Vista mail 1 26 Jan 2008
Can't Open Control Panel or Computer Props Brian Vista General 6 03 Nov 2007
retrieving key johnswansea Vista performance & maintenance 0 21 Aug 2007
Props Vista General 2 20 Mar 2007