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 } } } |