locked
Powershell - filter users by Database RRS feed

  • Question

  • Hi All,

    I am wanting something pretty simple, just a list of users on a particular database. I must be being a donkey as i can't see what i doing wrong. I am the first to admit i am new to powershell, but i was hoping i would be able to get something like this running ok on my own

    get-mailbox -filter {Database -eq "DG-MAIL\First Storage Group\Leavers"}

    i get an error running this.  Can anyone point me in the right direction? its driving me nuts!

    Cheers

    Dave


    Tuesday, August 5, 2008 11:20 AM

Answers

  • Another easy way:

    Get-mailbox –resultsize unlimited –database “DG-MAIL\First Storage Group\Leavers”

    If you want to use –filter:

    Get-mailbox -filter {Database -eq "CN=Mailbox Database,CN=First Storage Group,CN=InformationStore,CN=SGC,CN=Servers,CN=Exchange Administrative Group (FYDIBOHF23SPDLT),CN=Administrative Groups,CN=Organization,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=SG,DC=com"}

    The orange part is that database’s “DistinguishedName”, you can get it from the cmdlet below:

    Get-mailboxdatabase “DG-MAIL\First Storage Group\Leavers” | fl

     

    Thursday, August 7, 2008 4:30 AM
  • Hi Dave,

     

    Its better to use pipe to filter the result, instead of using –filter switch.

     

    Use this one…

    Get-Mailbox -ResultSize Unlimited | Where{$_.Database -eq "DG-MAIL\First Storage Group\Leavers"}

     

    This is for your advance reference to find other details for indivudial mailboxes like TotalItemSize, ItemCount, LastLogonTime, LastLogoffTime, LastLoggedOnUserAccount

    EMC - Where are Mailbox Total Items & Size (KB) Columns?

    Tuesday, August 5, 2008 11:53 AM

All replies

  • Hi Dave,

     

    Its better to use pipe to filter the result, instead of using –filter switch.

     

    Use this one…

    Get-Mailbox -ResultSize Unlimited | Where{$_.Database -eq "DG-MAIL\First Storage Group\Leavers"}

     

    This is for your advance reference to find other details for indivudial mailboxes like TotalItemSize, ItemCount, LastLogonTime, LastLogoffTime, LastLoggedOnUserAccount

    EMC - Where are Mailbox Total Items & Size (KB) Columns?

    Tuesday, August 5, 2008 11:53 AM
  • Thanks for your reply amir - i will try it tonight. I'm sure it will work though!

    Is there a reason that i can't use the -filter swich or rather i shouldn't use the filter switch? all the examples i have seen seem to use this...

    Thanks

    Dave
    Tuesday, August 5, 2008 1:06 PM
  • Another easy way:

    Get-mailbox –resultsize unlimited –database “DG-MAIL\First Storage Group\Leavers”

    If you want to use –filter:

    Get-mailbox -filter {Database -eq "CN=Mailbox Database,CN=First Storage Group,CN=InformationStore,CN=SGC,CN=Servers,CN=Exchange Administrative Group (FYDIBOHF23SPDLT),CN=Administrative Groups,CN=Organization,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=SG,DC=com"}

    The orange part is that database’s “DistinguishedName”, you can get it from the cmdlet below:

    Get-mailboxdatabase “DG-MAIL\First Storage Group\Leavers” | fl

     

    Thursday, August 7, 2008 4:30 AM
  • Yep, the -database switch would be the simplest way to do this
    Thursday, August 7, 2008 1:12 PM
  • Hi, David. Did you triy Amit and my methods? Does it work?

    Friday, August 8, 2008 1:23 AM
  • Hi, David, I suppose your question has been answered, and I'd like to change the status to "Marked as answer", please feel free to post here if you have any update

    Monday, August 11, 2008 1:36 AM
  • yes thanks for all who replied - that is it sorted now.

    thanks for the help chaps.
    Monday, August 11, 2008 5:38 PM
  • Easiest way I've found to do this is:

    get-mailboxdatabase "Databasename" |get-mailbox

    No filters, and two really common, easy commands and a pipe.  If you just want the names, then this:

    get-mailboxdatabase "Databasename" |get-mailbox |Fl Name

    I know you've sorted it already, just wanted to post a solution I used that I hadn't seen.

    Thanks.

    Thursday, September 7, 2017 1:54 PM