We use cookies to improve your experience.
By your continued use of this site you accept such use.
For more details please see our privacy policy and cookies policy.

Script repository

Delete all user data from mobile devices

February 18, 2021 Views: 2676

The script deletes all user data from all Exchange ActiveSync devices that belong to the user.

To use the script with Adaxes, you will need to create custom commands executed on User objects.

For more information on creating custom commands, see Create a Custom Command.

Parameters:

  • $exchangeServer - Specifies the fully qualified domain name or IP address of your Exchange Server.
Edit Remove
PowerShell
$exchangeServer = "Exchangeserver.domain.com" # TODO: Modify me

try
{
    $session = New-PSSession -connectionURI "http://$exchangeServer/powershell" -ConfigurationName Microsoft.Exchange
    Import-PSSession -session $session -AllowClobber -DisableNameChecking

    $Target = "%username%"
    Get-ActiveSyncDeviceStatistics -Mailbox $Target | foreach { Clear-ActiveSyncDevice $_.Identity }
}
finally
{
    Remove-PSSession -Session $session
}
Comments 2
avatar
kmhuglen87 Mar 20, 2023
I attempt to use this script against a user and i'm running into the following error:

Couldn't find '{USERNAME}' as a recipient. Stack trace: at <ScriptBlock><Process>, <No file>: line 44

Where USERNAME is the username of the account. i tried changing the Username value to UPN and Email attributes. neither option seems to make a difference. Any ideas?
avatar
Support Mar 21, 2023
Hello,

The error is not related to the script or Adaxes. It is returned by the Get-ActiveSyncDeviceStatistics cmdlet as it cannot find the account. Such a behaviour can occur if you delete the user somewhere in your script before running the cmdlet.
Leave a comment
Loading...

Got questions?

Support Questions & Answers