I wrote a quick Powershell script that will output an htm file of all the ActiveSync devices on an Exchange server. Just take off the .txt and using the Exchange Management Shell navigate to the directory where you have the script type in the command ./getactivesyncdevices.ps1 . The script will output the results to a file called getactivesyncdevices.htm.
$daysago = 7
@(
write-output '<html><head><title>Exchange 2007 ActiveSync Devices</title></head><body>'
write-output '<p><strong>Exchange 2007 ActiveSync Devices as of ' (get-date) '</strong></p>'
write-output '<p style="font-weight: bold; color: red;">Red = No Sync Attempts in ' $daysago ' Days</p>'
write-output '<table border="1" cellpadding="5"><tr><th>User</th><th>ActiveSync Device(s)</th></tr>'
$mailboxes = get-mailbox | sort -property name | select-object name,alias
foreach ($mailbox in $mailboxes)
{
$devices = get-activesyncdevicestatistics -mailbox $mailbox.alias
if ($devices -ne $null)
{
write-output '<tr><td>' $mailbox.name '</td><td>'
foreach ($device in $devices)
{
if ([datetime]$device.LastSyncAttemptTime -gt [datetime]::Now.AddDays(-$daysago) )
{
write-output '<p>'
}
else
{
write-output '<p style="font-weight: bold; color: red;">'
}
write-output 'ID:' $device.DeviceId '<br />'
write-output 'First Sync:' $device.FirstSyncTime '<br />'
write-output 'Last Sync:' $device.LastSuccessSync '<br />'
write-output 'Last Sync Attempt:' $device.LastSyncAttemptTime '<br />'
write-output 'Type:' $device.DeviceType '<br />'
write-output 'Model:' $device.DeviceModel '<br />'
write-output 'OS:' $device.DeviceOS '<br />'
write-output '</p>'
}
write-output '</td></tr>'
}
}
write-output '</table></body></html>'
) | out-file GetActiveSyncDevices.htm
No comments:
Post a Comment