Maintain control of your Microsoft Office 365 email data
Post Reply
kevz0r
Veeam Vanguard
Posts: 9
Liked: 1 time
Joined: Aug 18, 2017 2:16 am
Full Name: KA
Contact:

Powershell VEX-Mailbox filtering

Post by kevz0r » Jun 18, 2018 5:45 pm

Hi guys,

I'm having a problem filtering out mailboxes when there are two people with the same name.

So I would normally run a command like this:

Code: Select all

$mailbox = Get-VEXMailbox -Database $database -Name "Joe Bloggs"
But in my case there are two Joe Bloggs's with different email addresses so the output is:

Id : 4460fb58-34cf-488c-8cb2-f17721788a26
Name : Joe Bloggs
Email : joe.bloggs@company.com
IsDeleted : False
IsArchive : False

Id : a59e4551-b367-499e-84c7-1159459be40e
Name : Joe Bloggs
Email : joebloggs@company.com
IsDeleted : False
IsArchive : False

Which means when I run this command:

Code: Select all

Get-VEXFolder -Mailbox $mailbox
I get this error:

Get-VEXFolder : Cannot convert 'Joe Bloggs Joe Bloggs' to the type 'Veeam.Exchange.PowerShell.Model.Items.VEXMailbox' required by parameter 'Mailbox'. Specified
method is not supported.
At line:1 char:24
+ Get-VEXFolder -Mailbox $mailbox
+ ~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-VEXFolder], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgument,Veeam.Exchange.PowerShell.Cmdlets.Items.GetVEXFolder

I've tried to filter out the one I want with this command, using Where-Object:

Code: Select all

$mailbox = Get-VEXMailbox -Database $database -Name "Joe Bloggs" | Where-Object {$_.Email -eq "joebloggs@company.com"}
and

Code: Select all

$mailbox = Get-VEXMailbox -Database $database -Name "Joe Bloggs" | Where-Object {$_.Id -eq "a59e4551-b367-499e-84c7-1159459be40e"}
But it still returns the two mailboxes and gives the same error.

Am I missing something obvious here?

Thanks!

final
Enthusiast
Posts: 32
Liked: 11 times
Joined: Aug 14, 2016 7:19 pm
Contact:

Re: Powershell VEX-Mailbox filtering

Post by final » Jun 19, 2018 9:40 am

the Where-Object cmdlet won't help you regarding the error message as it only filters the results from get-vexmailbox after Get-VEXMailbox has returned everything.

And indeed, Get-VEXMailbox seems to be only able to filter by name. Worse than that, according to your error message (I don't have two mailboxes with the same name), it looks like the name of a mailbox is used as a unique identifier internally. This would of course be a design flaw as the name of a mailbox is not necessarily unique.

That being said, I'm not sure why the filter with Where-Object doesn't work, because it does filter properly for me:

Code: Select all

> $mailbox = Get-VEXMailbox -Database $db
> $mailbox.Count
353
> ($mailbox | ? {$_.email -match "support" }).Count
1

Mike Resseler
Product Manager
Posts: 5740
Liked: 611 times
Joined: Feb 08, 2013 3:08 pm
Full Name: Mike Resseler
Location: Belgium
Contact:

Re: Powershell VEX-Mailbox filtering

Post by Mike Resseler » Jun 21, 2018 5:53 am

Final,

Thanks for the information and feedback. I'm not sure if we have this scenario tested but we will look into it as soon as possible.

Vasiliy.Semendiy
Veeam Software
Posts: 4
Liked: never
Joined: Jul 07, 2017 8:36 am
Full Name: Vasiliy.Semendiy
Contact:

Re: Powershell VEX-Mailbox filtering

Post by Vasiliy.Semendiy » Jun 21, 2018 2:08 pm

Hello!

I created two users with the same name and different e-mail.

You need to use:
(Get-VEXMailbox -Database $ database -Name "Joe Bloggs") | Where-Object {$ _. Id -eq "a59e4551-b367-499e-84c7-1159459be40e"}

The only difference is that the first part uses parentheses.
And it works.

kevz0r
Veeam Vanguard
Posts: 9
Liked: 1 time
Joined: Aug 18, 2017 2:16 am
Full Name: KA
Contact:

Re: Powershell VEX-Mailbox filtering

Post by kevz0r » Jun 22, 2018 6:23 pm

Thanks very much guys.

Vasiliy I can confirm that works for me too - I knew I had to be missing something.

Final - I ended up working with your solution - basically I didn't use the "-Name" in the Get-VEXMailbox command and was able to filter after that.

Appreciate the help guys

Mike Resseler
Product Manager
Posts: 5740
Liked: 611 times
Joined: Feb 08, 2013 3:08 pm
Full Name: Mike Resseler
Location: Belgium
Contact:

Re: Powershell VEX-Mailbox filtering

Post by Mike Resseler » Jun 25, 2018 5:29 am

I'll let Vasiliy know. Thanks for getting back to us and confirm it works!

Cheers
Mike

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests