Search Exchange for mobile devices with IMEI

At work I have a bunch of HTC phones lieing around. Quite often I don’t have the password for the phone so normally I would have to send them to the vendor to get them unlocked. This is both time consuming and costly. With Exchange you have the posibility to use a recovery password to reset the phones password. So I developed this script that search for phones with a specific string in the IMEI no. The script displayes all matches, mailboxes associated with the phone and the recovery password if possible. Something like this:

Recovery password for ’35575701146176702′ belonging to John Wayne (jw) is: 81689180324104937573

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Add-PSSnapin -name Microsoft.Exchange.Management.Powershell.Admin
 
$searchString = Read-Host "Enter IMEI no. to search for:"
"Searching for IMEI containing '" + $searchString + "'..."
 
$mailboxes = Get-Mailbox
 
foreach( $mailbox in $mailboxes )
{
    $deviceStats = Get-ActiveSyncDeviceStatistics -Mailbox $mailbox -ShowRecoveryPassword $true
    foreach( $deviceStat in $deviceStats )
    {
        if( $deviceStat.DeviceIMEI -like "*" + $searchString + "*" )
        {
            "Recovery password for '" + $deviceStat.DeviceIMEI + "' belonging to " + $mailbox.DisplayName + " (" + $mailbox.SamAccountName + ") is: " + $deviceStat.RecoveryPassword
            break
        }
    }
}
  1. Hi,
    How can I get a list of all IMEI previously connected to the exchange server. I am trying to retrieve the IMEI from the exchange server…. Any assistance will be great…. preferably in visual basic syntax

    • René Iversen
    • June 25th, 2010

    @Albert
    Simply replace the if-statement with this:

    if( $deviceStat.DeviceIMEI -ne $null )

    and you also might want to delete line 3, 4, and 16.

  1. No trackbacks yet.