powershellexchange-serverexchange-server-2019

Why is Get-MobileDevice not returning the devices based on this filter?


I am trying to query Exchange 2019 to return devices based on a users name but the filter I am using is not returning what I expect.

For example my mobile device record contains a UserDisplayName as follows

UserDisplayName         : Our.domain/Domain Sites/Corp/Todd D. Welch

When I run the bellow command it returns my record as I would expect along with anyone else with the name Todd

Get-MobileDevice -filter {UserDisplayName -like '*todd*'}

But when I run this more specific query it returns no results

Get-MobileDevice -filter {UserDisplayName -like '*todd*welch*'}

To me it seems like the above command should return just my device information and I am not seeing why it is not. Any help would be greatly appreciated.


Solution

  • Maybe you can chain your criterias as the Get-MobileDevice docu states:

    You can chain multiple search criteria together using the logical operators -and and -or. For example, {) -and } or {( -and ) -or }.

    So you could try :

    $str = "Our.domain/Domain Sites/Corp/Todd D. Welch"
    
    ($str -like '*todd*') -and ( $str -like '*welch*') 
    

    Which returns True in the online version .

    Hope that helps.