In this Powershell sample (created with ASE) – its possible to create a simple form to let Helpdesk manage Activesync Devices, this is done by finding and wipe/unwipe the device. Feel free to change and clean-up 😉 – Try ASE – http://adminscripteditor.com/ – Its a great editor.

####################################################################
# Program..........: ASExWipe.ps1                            #
# Author...........: Kåre Rude Andersen ([email protected])          #
# Bagground........: Utility to let helpdesk manage Activesync     #
# .................: devices.                                      #
####################################################################

#region Script Settings
#<ScriptSettings xmlns="http://tempuri.org/ScriptSettings.xsd">
#  <ScriptPackager>
#    <process>powershell.exe</process>
#    <arguments />
#    <extractdir>c:\scripts</extractdir>
#    <files />
#    <usedefaulticon>true</usedefaulticon>
#    <showinsystray>false</showinsystray>
#    <altcreds>true</altcreds>
#    <efs>false</efs>
#    <ntfs>false</ntfs>
#    <local>false</local>
#    <username>excadmin</username>
#    <domain>coretech.intra</domain>
#    <abortonfail>true</abortonfail>
#    <product />
#    <version>1.0.0.1</version>
#    <versionstring />
#    <comments />
#    <includeinterpreter>false</includeinterpreter>
#    <forcecomregistration>true</forcecomregistration>
#    <consolemode>false</consolemode>
#    <EnableChangelog>false</EnableChangelog>
#    <AutoBackup>false</AutoBackup>
#    <snapinforce>false</snapinforce>
#    <snapinshowprogress>false</snapinshowprogress>
#    <snapinautoadd>0</snapinautoadd>
#    <snapinpermanentpath />
#  </ScriptPackager>
#</ScriptSettings>
#endregion

#PowerShell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\Bin\ExShell.Msc1" -Command ". '<script.ps1>'"
$ErrorActionPreference = "SilentlyContinue"
#region ScriptForm Designer

#region Constructor

[void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")

#endregion

#region Post-Constructor Custom Code
# Add-PSSnapin "Microsoft.Exchange.Management.PowerShell.Admin"
#endregion

#region Form Creation
#Warning: It is recommended that changes inside this region be handled using the ScriptForm Designer.
#When working with the ScriptForm designer this region and any changes within may be overwritten.
#~~< Form1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$Form1 = New-Object System.Windows.Forms.Form
$Form1.ClientSize = New-Object System.Drawing.Size(713, 555)
$Form1.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::Fixed3D
$Form1.Text = "ActiveSync handling"
#~~< TextBox10 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$TextBox10 = New-Object System.Windows.Forms.TextBox
$TextBox10.BorderStyle = [System.Windows.Forms.BorderStyle]::FixedSingle
$TextBox10.Location = New-Object System.Drawing.Point(37, 12)
$TextBox10.ReadOnly = $true
$TextBox10.ShortcutsEnabled = $false
$TextBox10.Size = New-Object System.Drawing.Size(643, 20)
$TextBox10.TabIndex = 9
$TextBox10.Text = "Start by typing a username or email address,  Then choose the device and press wipe or unwipe."
$TextBox10.TextAlign = [System.Windows.Forms.HorizontalAlignment]::Center
$TextBox10.BackColor = [System.Drawing.SystemColors]::ActiveBorder
$TextBox10.Cursor = [System.Windows.Forms.Cursors]::Default
#~~< Button1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$Button1 = New-Object System.Windows.Forms.Button
$Button1.Location = New-Object System.Drawing.Point(524, 476)
$Button1.Size = New-Object System.Drawing.Size(75, 23)
$Button1.TabIndex = 8
$Button1.Text = "UnWipe Activesyncdevice"
$Button1.UseVisualStyleBackColor = $true
$Button1.add_Click({ ButtonUnWipeActiveClick($Button1) })
#~~< ListBox1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$ListBox1 = New-Object System.Windows.Forms.ListBox
$ListBox1.FormattingEnabled = $true
$ListBox1.HorizontalScrollbar = $true
$ListBox1.Location = New-Object System.Drawing.Point(37, 78)
$ListBox1.ScrollAlwaysVisible = $true
$ListBox1.Size = New-Object System.Drawing.Size(643, 368)
$ListBox1.TabIndex = 7
$ListBox1.Cursor = [System.Windows.Forms.Cursors]::Hand
#~~< Button4 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$Button4 = New-Object System.Windows.Forms.Button
$Button4.Location = New-Object System.Drawing.Point(455, 49)
$Button4.Size = New-Object System.Drawing.Size(225, 23)
$Button4.TabIndex = 5
$Button4.Text = "Get Device"
$Button4.UseVisualStyleBackColor = $true
$Button4.add_Click({ ButtonGetDeviceClick($Button4) })
#~~< TextBox1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$TextBox1 = New-Object System.Windows.Forms.TextBox
$TextBox1.ImeMode = [System.Windows.Forms.ImeMode]::NoControl
$TextBox1.Location = New-Object System.Drawing.Point(37, 51)
$TextBox1.Size = New-Object System.Drawing.Size(412, 20)
$TextBox1.TabIndex = 4
$TextBox1.Text = "Type Username or email (like 52405)"
#~~< Button3 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$Button3 = New-Object System.Windows.Forms.Button
$Button3.Location = New-Object System.Drawing.Point(605, 476)
$Button3.Size = New-Object System.Drawing.Size(75, 23)
$Button3.TabIndex = 0
$Button3.Text = "Done"
$Button3.UseVisualStyleBackColor = $true
$Button3.add_Click({ ButtonDoneClick($Button3) })
#~~< Button2 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$Button2 = New-Object System.Windows.Forms.Button
$Button2.Location = New-Object System.Drawing.Point(443, 476)
$Button2.Size = New-Object System.Drawing.Size(75, 23)
$Button2.TabIndex = 3
$Button2.Text = "Wipe Activesyncdevice"
$Button2.UseVisualStyleBackColor = $true
$Button2.add_Click({ ButtonWipeActiveClick($Button2) })
$Form1.Controls.Add($TextBox10)
$Form1.Controls.Add($Button1)
$Form1.Controls.Add($ListBox1)
$Form1.Controls.Add($Button4)
$Form1.Controls.Add($TextBox1)
$Form1.Controls.Add($Button3)
$Form1.Controls.Add($Button2)

#endregion

#region Custom Code

#endregion

#region Event Loop

function Main
{
[System.Windows.Forms.Application]::EnableVisualStyles()
[System.Windows.Forms.Application]::Run($Form1)
}

#endregion

#endregion

#region Event Handlers

function ButtonDoneClick($object)
{
$Form1.Close()
}

function ButtonGetDeviceClick($object)
{
$Listbox1.items.clear()
$AllData = Get-ActiveSyncDeviceStatistics -ea SilentlyContinue -ev MyError -Mailbox:$TextBox1.Text | Select-Object devicefriendlyname, FirstSyncTime, LastSuccessSync, DeviceWipeSentTime, DeviceModel, DeviceIMEI, DeviceOS, identity
if ($MyError -ne "")
{
$ListBox1.Items.Add("Not Found " + $myerror)
$MyError = ""
}
else
{
foreach ($Alt in $AllData)
{
[String]$Ident = $Alt.Identity
$id = $ident.substring(0, $Ident.indexof("\"))
[void]$ListBox1.Items.Add($Id + ", " + $Alt)
}
}
�
}
�
function ButtonWipeActiveClick($object)
{
[String]$ChoosedDevice = $ListBox1.SelectedItem
$WipeThisDevice = $choosedDevice.substring($ChoosedDevice.indexof("Identity=") + 9, ( ($ChoosedDevice.Length)-( $ChoosedDevice.indexof("Identity=") + 9 ) )-1)
�
$rc = Show-Msgbox -message "Are you sure you want to Wipe this device?" `
-icon "exclamation" -button "YesNo" -title "Wipe Device $wipethisdevice ?"
�
switch($rc)
{
"Yes" { Clear-ActiveSyncDevice -Identity $WipeThisDevice -cancel $false -confirm:$false }
"No" { $TextBox1.Text = "Wise move." }
}
�
}
�
function Show-Msgbox
{
Param([string]$message = $(Throw "You must specify Yes or No"),
[string]$button = "YesNo",
[string]$icon = "Critical",
[string]$title = "Message Box"
)
�
[reflection.assembly]::loadwithpartialname("microsoft.visualbasic") | Out-Null
�
[microsoft.visualbasic.interaction]::Msgbox($message, "$button,$icon", $title)
�
}

function ButtonUnWipeActiveClick($object)
{
[String]$ChoosedDevice = $ListBox1.SelectedItem
$UnWipeThisDevice = $choosedDevice.substring($ChoosedDevice.indexof("Identity=") + 9, ( ($ChoosedDevice.Length)-( $ChoosedDevice.indexof("Identity=") + 9 ) )-1)
�
$rc = Show-Msgbox -message "Are you sure you want to UNwipe this device?" `
-icon "exclamation" -button "YesNo" -title "UNwipe Device $UNwipethisdevice ?"
�
switch($rc)
{
"Yes" { Clear-ActiveSyncDevice -Identity $UNwipeThisDevice -cancel $true -confirm:$false }
"No" { $TextBox1.Text = "Wise move." }
}
�
}

Main # This call must remain below all other event functions

#endregion
�
�
#