Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 293
  • Last Modified:

Get all mailboxes, but not from specific database

I have 7 databases on my Exchange 2010 server. Lets call them A, B, C, D, E, F and G.
I need to get all mailboxes from all databases, except database C and F.

I have tried with
Get-Mailbox -ResultSize Unlimited | Where {MailboxDatabase -ne 'C' OR 'F'}

Open in new window

But without any success.

Can anyone help me here?
0
Kasper Katzmann
Asked:
Kasper Katzmann
  • 2
1 Solution
 
Stelian StanCommented:
You can do one database at the time and exported to a txt or csv file:

Get-MailboxDatabase "IT" | Get-Mailbox | Out-File C:\it.txt

Open in new window

Get-MailboxDatabase "IT" | Get-Mailbox | Export-Cvs C:\it.csv

Open in new window

0
 
Kasper KatzmannAuthor Commented:
I've found the solution by juggling a little bit around:
Get-Mailbox | `
	Where-Object {`
		($_.Database -ne 'C') -AND `
		($_.Database -ne 'F')}

Open in new window

0
 
Kasper KatzmannAuthor Commented:
It solves the problem and answers the question
0

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now