Script Repository


Wipe all mobile devices

February 25, 2021
232

The script wipes all mobile devices of the target mailbox. The script can be executed in a custom command, business rule or scheduled task.

Edit Remove
PowerShell
# Get mailbox parameters
$mailboxParams = $Context.TargetObject.GetMailParameters("ADM_GET_EXCHANGE_PARAMS_FLAGS_NONE")

# Get active sync feature
$activeSync = $mailboxParams.MailboxFeatures.GetItemByType("ADM_EXCHANGE_MAILBOXFEATURETYPE_ACTIVESYNC")

# Wipe all mobile devices
foreach ($mobileDevice in $activeSync.MobileDevices)
{
    $mobileDevice.WipeStatus = "ADM_MOBILE_DEVICE_WIPE_STATUS_WIPEPENDING"
}

# Save changes
$Context.TargetObject.SetMailParameters($mailboxParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")

Comments ( 4 )
avatar
Remco
Jan 27, 2021
Wil this wipe the complete mobile device or only the corporate data?

Thnx Remco
avatar
Support
Jan 28, 2021
Hello Remco,

To perform the wipe, Adaxes uses the Clear-MobileDevice cmdlet which deletes all data from a mobile phone. For more details about the cmdlet, have a look at the following Microsoft article: https://docs.microsoft.com/en-us/powershell/module/exchange/clear-mobiledevice?view=exchange-ps.
avatar
Remco Tiel
Jan 28, 2021
The clear-mobiledevice has a switch -accountonly. How to add this switch to the above script? I do not want to wipe the complete device.

Thnx remco
avatar
Support
Jan 29, 2021
Hello Remco,

It can only be done by using the Clear-MobileDevice cmdlet itself in the script. For information on how to connect to Exchange in PowerShell scripts executed in Adaxes, have a look at the following article in our repository: https://www.adaxes.com/script-repository/connect-to-exchange-with-powershell-s506.htm.
Leave a comment