Get-mailbox and Pipe

rated by 0 users
This post has 4 Replies | 3 Followers

Not Ranked
Posts 2
jan.bezdek Posted: 09-12-2011 5:36 AM

Hello,

Why the following cmd-lets return the different results?

I expected the same output.

"*info*" | Get-Mailbox -filter { emailaddresses -like $_ } |select name,emailaddresses |ft -autosize

Name            EmailAddresses
----            --------------
Sys_ucet_sluzeb {SMTP:sysinfo@skoda.cz, X400:C=us;A= ;P=SKODA;O=Exchange;S=sysinfo;}


Get-Mailbox -filter { emailaddresses -like "*info*" } |select name,emailaddresses |ft -autosize

Name            EmailAddresses
----            --------------
Sys_ucet_sluzeb {SMTP:sysinfo@skoda.cz, X400:C=us;A= ;P=SKODA;O=Exchange;S=sysinfo;}
Hlaváček Milan  {smtp:info@skoda.cz, SMTP:milan.hlavacek@skoda.cz, X400:C=us;A= ;P=SKODA;O=Exchange;S=Hlavacek;G=Milan;}

 

 

Thanks…

Jan

Not Ranked
Posts 4

Hi,

Both the cmdlets gives the same output. Please find the eg below,

PS C:\> "*test*" | Get-Mailbox -filter { emailaddresses -like $_ } |select name,emailaddresses |ft -autosize

Name              EmailAddresses
----              --------------
Test User 1       {SMTP:Test.User1@etst.netapp.com, smtp:TestUser1@etst.netapp.com, smtp:TestUser1@hqtst.netapp.com}
Test User 2       {smtp:TESTUSER2@etst.netapp.com, smtp:TESTUSER2@hqtst.netapp.com, SMTP:Test.User2@etst.netapp.com}
Test User 3       {SMTP:Test.User3@etst.netapp.com, smtp:TESTUSER3@hqtst.netapp.com, smtp:TESTUSER3@etst.netapp.com}
TestMDB01         {smtp:TestMDB01@hqtst.netapp.com, SMTP:TestMDB01@etst.netapp.com}
TestMDB02         {smtp:TestMDB02@hqtst.netapp.com, SMTP:TestMDB02@etst.netapp.com}
TestMDB34         {smtp:TestMDB34@hqtst.netapp.com, SMTP:TestMDB34@etst.netapp.com}
TestMDB35         {smtp:TestMDB35@hqtst.netapp.com, SMTP:TestMDB35@etst.netapp.com}
Gopi Test         {smtp:gopitest@hqtst.netapp.com, smtp:gopitest@etst.netapp.com, SMTP:Gopi.Test@etst.netapp.com}
Anand Test        {smtp:anandtest@hqtst.netapp.com, smtp:anandtest@etst.netapp.com, SMTP:Anand.Test@etst.netapp.com}
Ed Crowley (Test) {SMTP:Ed.Crowley@etst.netapp.com, smtp:ecrowley@hqtst.netapp.com, smtp:ecrowley@etst.netapp.com}
dsamtest          {smtp:dsamtest@hqtst.netapp.com, SMTP:dsamtest@etst.netapp.com}
Test nmatt        {smtp:tstnmatt@hqtst.netapp.com, smtp:tstnmatt@etst.netapp.com, SMTP:Test.nmatt@etst.netapp.com}


PS C:\> Get-Mailbox -filter { emailaddresses -like "*test*" } |select name,emailaddresses |ft -autosize

Name        EmailAddresses
----        --------------
Test User 1 {SMTP:Test.User1@etst.netapp.com, smtp:TestUser1@etst.netapp.com, smtp:TestUser1@hqtst.netapp.com}
Test User 2 {smtp:TESTUSER2@etst.netapp.com, smtp:TESTUSER2@hqtst.netapp.com, SMTP:Test.User2@etst.netapp.com}
Test User 3 {SMTP:Test.User3@etst.netapp.com, smtp:TESTUSER3@hqtst.netapp.com, smtp:TESTUSER3@etst.netapp.com}
TestMDB01   {smtp:TestMDB01@hqtst.netapp.com, SMTP:TestMDB01@etst.netapp.com}
TestMDB02   {smtp:TestMDB02@hqtst.netapp.com, SMTP:TestMDB02@etst.netapp.com}
TestMDB34   {smtp:TestMDB34@hqtst.netapp.com, SMTP:TestMDB34@etst.netapp.com}
TestMDB35   {smtp:TestMDB35@hqtst.netapp.com, SMTP:TestMDB35@etst.netapp.com}
Gopi Test   {smtp:gopitest@hqtst.netapp.com, smtp:gopitest@etst.netapp.com, SMTP:Gopi.Test@etst.netapp.com}
Anand Test  {smtp:anandtest@hqtst.netapp.com, smtp:anandtest@etst.netapp.com, SMTP:Anand.Test@etst.netapp.com}
dsamtest    {smtp:dsamtest@hqtst.netapp.com, SMTP:dsamtest@etst.netapp.com}
Test nmatt  {smtp:tstnmatt@hqtst.netapp.com, smtp:tstnmatt@etst.netapp.com, SMTP:Test.nmatt@etst.netapp.com}

And sry for very late response...

Regards

Not Ranked
Posts 2

Hi,

Thanks for your answer. Your outputs looks to be OK. 

I can give the next example, where you can see my problem:

PS C:\SCRIPTS\ps> "*test*" | Get-Mailbox -filter { emailaddresses -like $_ } |select name,emailaddresses |ft -autosize

 

Name                 EmailAddresses

----                 --------------

ELC Test             {SMTP:test.elc@skoda.cz, X400:C=us;A= ;P=SKODA;O=Exchange;S=ELC;G=Test;}

User Testovaci       {X400:C=us;A= ;P=SKODA;O=Exchange;S=User;G=Testovaci;, SMTP:test.user@skoda.cz}

Vag Test             {SMTP:test.vag@skoda.cz, X400:C=us;A= ;P=SKODA;O=Exchange;S=Vag;G=Test;}

TRN Test             {SMTP:test.trn@skoda.cz}

Test PuFo            {SMTP:test.pufo@skoda.cz, X400:C=us;A= ;P=SKODA;O=Exchange;S=test.pufo;}

Calta_test           {X400:C=us;A= ;P=SKODA;O=Exchange;S=Calta;, SMTP:calta@skoda.cz}

PARS Test            {SMTP:test.pars@skoda.cz, X400:C=us;A= ;P=SKODA;O=Exchange;S=PARS;G=Test;}

Petr.TestVag         {X400:C=us;A= ;P=SKODA;O=Exchange;S=TestVag;G=Petr;, SMTP:petr.testvag@skoda.cz}

MOVO Test            {SMTP:test.movo@skoda.cz, X400:C=us;A= ;P=SKODA;O=Exchange;S=MOVO;G=Test;}

extest_26bcaca6bd2e4 {X400:C=us;A= ;P=SKODA;O=Exchange;S=extest?26bcaca6bd2e4;, SMTP:extest_26bcaca6bd2e4@skoda.cz}

Testovaci Uzivatel   {X400:C=us;A= ;P=SKODA;O=Exchange;S=Uzivatel;G=Testovaci;, SMTP:testovaci.uzivatel@skoda.cz}

Android Test         {X400:C=us;A= ;P=SKODA;O=Exchange;S=Android;G=Test;, SMTP:test.android@skoda.cz}

GNZ Test             {SMTP:Test.GNZ@ganz-skoda.hu, smtp:test.gnz@skoda.cz}

 

The Mailbox for “Jan Bezděk” is missing. See bellow.

Why there is the Mailbox Calta_test. . I don’t know why, because there isn’t  string test in its smtp address.

 

PS C:\SCRIPTS\ps> Get-Mailbox -filter { emailaddresses -like "*test*" } |select name,emailaddresses |ft -autosize

 

Name                 EmailAddresses

----                 --------------

Bezděk Jan           {smtp:test.bezdek@skoda.cz, SMTP:jan.bezdek@skoda.cz}

ELC Test             {SMTP:test.elc@skoda.cz, X400:C=us;A= ;P=SKODA;O=Exchange;S=ELC;G=Test;}

User Testovaci       {X400:C=us;A= ;P=SKODA;O=Exchange;S=User;G=Testovaci;, SMTP:test.user@skoda.cz}

Vag Test             {SMTP:test.vag@skoda.cz, X400:C=us;A= ;P=SKODA;O=Exchange;S=Vag;G=Test;}

TRN Test             {SMTP:test.trn@skoda.cz}

Test PuFo            {SMTP:test.pufo@skoda.cz, X400:C=us;A= ;P=SKODA;O=Exchange;S=test.pufo;}

PARS Test            {SMTP:test.pars@skoda.cz, X400:C=us;A= ;P=SKODA;O=Exchange;S=PARS;G=Test;}

Petr.TestVag         {X400:C=us;A= ;P=SKODA;O=Exchange;S=TestVag;G=Petr;, SMTP:petr.testvag@skoda.cz}

MOVO Test            {SMTP:test.movo@skoda.cz, X400:C=us;A= ;P=SKODA;O=Exchange;S=MOVO;G=Test;}

extest_26bcaca6bd2e4 {X400:C=us;A= ;P=SKODA;O=Exchange;S=extest?26bcaca6bd2e4;, SMTP:extest_26bcaca6bd2e4@skoda.cz}

Testovaci Uzivatel   {X400:C=us;A= ;P=SKODA;O=Exchange;S=Uzivatel;G=Testovaci;, SMTP:testovaci.uzivatel@skoda.cz}

Android Test         {X400:C=us;A= ;P=SKODA;O=Exchange;S=Android;G=Test;, SMTP:test.android@skoda.cz}

GNZ Test             {SMTP:Test.GNZ@ganz-skoda.hu, smtp:test.gnz@skoda.cz}

Regards

jb 

Not Ranked
Posts 4

Hi,

Even I got the same problem when I try with other examples.

"*test*" | Get-Mailbox-filter....... checks for "test" in all the attributes rather than EmailAddresses. It really looks lik a bug for meSmile

Top 100 Contributor
Posts 27

I performed the same searches on a larger target rich environment. I switched to the DisplayName as the target of my searches.

 

Commands:

"*test*" | Get-Mailbox -filter { displayname -like $_} | ft displayname,name -auto

 

vs.

Get-Mailbox -filter { displayname -like "*test*"} | ft displayname,name -auto

 

Results:

Piped parameter returned 239 results

fixed text filter returned 232 results

 

I will concentrate on the extra results i received in order to show that the problem lies with the underlying processing of the -Filter and not actually with PowerShell. The -Filter relies on the underlying product (in this case with Exchange) to process the query.

 

1. the piped test hit on either the text within a display name ".. T&ES T.." (actually matching to "T&ES T" as a hit), or it hit on either the SamAccountName, alias, or UserPrincipalName which all started with 'test'.

 

2. the piped test hit on either the display name text "..TE-ST.." (actually matching to "TE-ST" as a hit), or to the SamAccountName or Alias that both had 'test' imbedded in the name.

 

3. the piped test hit on ".. Offsite Storage" (the "te St") in this case only the Alias also contained and imbedded 'test'

 

4. another "te St" hit this time SamAccountName, UserPrincipalName and Alias all contain an imbedded 'test'

 

5. Display name had no 'test' reference of any concoction (the display name did not even contain the letter 't') and only the UserPrincipalName contained 'test'

 

6. another imbedded blank "T Est" hit this time SamAccountName, UserPrincipalName and Alias all contain an imbedded 'test'

 

The long and the short of it is that a piped object is treated differently than an imbedded text in the filter parameter if you want accurate results you should probably not use a piped object as the target of a -Filter search. Most telling in my opinion was #5 where the DisplayName could not possibly be matched to 'test'. I've noticed before with Exchange that it tends to treat 'name' and 'displayname' (two different fields) as one an the same in many cases and i think that is the root of the issue here, that the resulting -Filter query that is processed by Exchange is in fact being processed outside of powershell and the results can be different.

Page 1 of 1 (5 items) | RSS
Copyright 2012 PowerShell.com. All rights reserved.