17 September 2015

Not able to mount database - Eseutil.exe to the rescue

The following error may occur:

[PS] D:\Data\mdb1\MDB1>Mount-Database mdb1 -Force -AcceptDataLoss
Failed to mount database "mdb1". Error: An Active Manager operation failed. Error: The database action failed. Error:
Operation failed with message: MapiExceptionDatabaseError: Unable to mount database. (hr=0x80004005, ec=1108)
Diagnostic context:
    Lid: 65256
    Lid: 10722   StoreEc: 0x454
    Lid: 1494    ---- Remote Context Beg ----
    Lid: 45120   dwParam: 0x592663
    Lid: 57728   dwParam: 0x5927CA
    Lid: 46144   dwParam: 0x5931BD
    Lid: 34880   dwParam: 0x5931BD
    Lid: 34760   StoreEc: 0xFFFFFB40
    Lid: 41344   Guid: f3254d9d-1279-4fb4-8ce9-6b830204afac
    Lid: 35200   dwParam: 0x10BC
    Lid: 46144   dwParam: 0x593816
    Lid: 34880   dwParam: 0x593816
    Lid: 54472   StoreEc: 0x1388
    Lid: 42184   StoreEc: 0x454
    Lid: 1750    ---- Remote Context End ----
    Lid: 1047    StoreEc: 0x454      [Database: MDB1, Server: sr-XXXXX-t.domain.lan]
    + CategoryInfo          : InvalidOperation: (MDB1:ADObjectId) [Mount-Database], InvalidOperationException
    + FullyQualifiedErrorId : [Server=SR-XXXXX-T,RequestId=32e76a8d-ed5f-4bc4-9a43-e84014d2a340,TimeStamp=9/17/2015 9:
   40:52 AM] [FailureCategory=Cmdlet-InvalidOperationException] BC20DD3D,Microsoft.Exchange.Management.SystemConfigur
  ationTasks.MountDatabase
    + PSComputerName        : sr-XXXX-t.domain.lan

After checking the disk space and all other obvious places do the following:

Copy all the original database and log files to somewhere safe. 
Then also copy them into a working directory. 
Eseutil will modify the files in situation so if it goes wrong you don't want your original files modified.

You need to have a copy of the database files (*.edb and *.stm) plus the transaction logs
(Exx*.log where xx is a number relating to the information store).
The location of the files is available from exchange system manager, but you really should know where they all are anyway.

From the database path run:

eseutil /mh databasename.edb

eseutil /p databasename.edb

eseutil /mh databasename.edb

Then  move all the log files away from Exchange log folder:
x:\databasename\Logs\*.* to x:\Temp\databasename\Logs\*.*

Then mount the database:

Mount-Database mdb1 -Force

ESEUTIL explanation:
Defragmentation
/D
Eseutil defragments the database files. This mode reduces the gross size on disk of the database (.edb) and streaming files (.stm) by discarding most empty pages and ad hoc indexes.
Repair
/P
Eseutil repairs corrupt database pages in an offline database but discards any that can't be fixed. In repair mode, the Eseutil utility fixes individual tables but does not adjust the relationships between tables. ISInteg should be used to check logical relationships between tables. 
Restore
/C
Eseutil displays the Restore.env file and controls hard recovery after restoration from online backup.
Recovery
/R
Eseutil replays transaction log files or rolls them forward to restore a database to internal consistency or to bring an older copy of a database up to date.
Integrity
/G
Eseutil verifies the page level and Extensible Storage Engine (ESE) level logical integrity of the database but does not verify database integrity at the Information Store level.
File Dump
/M
Eseutil displays headers of database files, transaction log files, and checkpoint files. The mode also displays database space allocation and metadata.
Checksum
/K
Eseutil verifies checksums on all pages in the database and streaming files.
Copy File
/Y
Eseutil performs a fast copy of very large files.

07 September 2015

Remove BlackBerry throttling policy from Exchange 2010

Find all mailboxes with the "BESPolicy"

Get-Mailbox -ResultSize Unlimited | where {$_.ThrottlingPolicy -eq "BESPolicy"}

Note - The policy name is capital sensitive

Set all found mailboxes to the default throttling policy


Get-Mailbox -ResultSize Unlimited | where {$_.ThrottlingPolicy -eq "BESPolicy"} | Set-Mailbox -ThrottlingPolicy DefaultThrottlingPolicy_7371b684-08b6-4d0a-9116-34ade049caf8

Remove the BESPolicy

[PS] Get-ThrottlingPolicy BESPolicy | Remove-ThrottlingPolicy

Confirm
Are you sure you want to perform this action?
Removing throttling policy "BESPolicy".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [?] Help (default is "Y"): y

01 September 2015

Display all active sync devices

Need a report on all the ActiveSync devices in Exchange 2010 & 2013?
This oneliner will do just that:

Get-MobileDevice | select-object DeviceModel,FriendlyName,DeviceOS,UserDisplayName | 
sort-object devicemodel | Out-GridView

Or get an overview of the number of types per type. (May take a while, depending on the number activesync devices in your organisation)

(Get-CASMailbox -ResultSize unlimited -filter {HasActiveSyncDevicepartnership -eq $true} | Get-Mailbox) | 
Foreach {Get-MobileDeviceStatistics -Mailbox $_} | Group Devicemodel | Sort Count -Descending | Select Count, Name

Find and remove all devices that have not synced over 30 days:

$DevicesToRemove = Get-MobileDevice -result unlimited | 
Get-MobileDeviceStatistics | where {$_.LastSuccessSync -le (Get-Date).AddDays("-30")}
$DevicesToRemove | foreach-object {Remove-MobileDevice ([string]$_.Guid) -confirm:$false}