Run Microsoft Exchange cmdlets offline

Couple of months ago I wrote about running Lync cmdlets offline. Being a Consultant this helps a lot as I can document and find about the customers environment without connecting to the live Lync environment. Extending the same concept to other Microsoft products which use Power shell (which means pretty much every Microsoft product esp. when PowerShell is part of Microsoft Common Engineering Criteria) is fairly straightforward.

In this post I demonstrate how you can access Exchange cmdlets offline.

Purpose
The script allows you to execute Exchange cmdlets on your local machine (which may or may not have Exchange Management Shell). This is achieved by using XML files which are exported using export-clixml from Live Lync environment.

Script Pre-requisites
The script requires access to Exchange XML files generated using Exchange Management Shell. The files can be generated in couple of different ways. The generated filename should have the cmdlets name prefixed to it (eg: get-mailbox cmdlets filename should be get-mailbox.xml).

Below is a sample snippet you can use to export most of the Exchange configuration into XML files.

foreach ($a in get-command get-* | ? {$_.commandtype -eq "Function"})
{ If (($a.name -match "Get-ActiveSyncDeviceStatistics") -or ($a.name -match "Get-ADPermission") -or
     ($a.name -match "Get-CalendarDiagnosticLog") -or ($a.name -match "Get-CalendarNotification") -or ($a.name -match "Get-CalendarProcessing") -or
     ($a.name -match "Get-DistributionGroupMember") -or ($a.name -match "Get-FailedContentIndexDocuments") -or ($a.name -match "Get-FederatedDomainProof") -or
     ($a.name -match "Get-FederationInformation") -or ($a.name -match "Get-LogonStatistics") -or ($a.name -match "Get-MailboxAutoReplyConfiguration") -or
     ($a.name -match "Get-MailboxCalendarConfiguration") -or ($a.name -match "Get-MailboxCalendarFolder") -or ($a.name -match "Get-MailboxFolderPermission") -or
     ($a.name -match "Get-MailboxFolderStatistics") -or ($a.name -match "Get-MailboxJunkEmailConfiguration") -or ($a.name -match "Get-MailboxMessageConfiguration") -or
     ($a.name -match "Get-MailboxPermission") -or ($a.name -match "Get-MailboxRegionalConfiguration") -or ($a.name -match "Get-MailboxRestoreRequestStatistics") -or
     ($a.name -match "Get-MailboxSentItemsConfiguration") -or ($a.name -match "Get-MailboxSpellingConfiguration") -or ($a.name -match "Get-MailboxStatistics") -or
     ($a.name -match "Get-ManagementRoleEntry") -or ($a.name -match "Get-MessageTrackingReport") -or ($a.name -match "Get-MoveRequestStatistics") -or
     ($a.name -match "Get-PhysicalAvailabilityReport") -or ($a.name -match "Get-PublicFolderAdministrativePermission") -or ($a.name -match "Get-PublicFolderClientPermission") -or
     ($a.name -match "Get-PublicFolderItemStatistics") -or ($a.name -match "Get-RoleGroupMember") -or ($a.name -match "Get-ServiceAvailabilityReport") -or
     ($a.name -match "Get-StoreUsageStatistics") -or ($a.name -match "Get-UMCallSummaryReport") -or ($a.name -match "Get-UMMailboxConfiguration") -or
     ($a.name -match "Get-ADPermission1") -or ($a.name -match "Get-TextMessagingAccount") -or ($a.name -match "Get-UMCallDataRecord")
     ){}
  Else {&$a -erroraction silentlycontinue | Export-Clixml -path $a".xml"}
}

The screenshot below shows the above snippet being run and the resulting XML files.

image

Once you have exported the XML files, copy the files over to your local machine. The exported XML files can be extremely large but if you zip them up and reduce the size by almost 5-10 times!. You do not have to copy all the XML files if you don’t want the output of all the cmdlets.

Script Execution

Download the script from here. On your local machine open PowerShell and launch the script. The script accepts only one parameter folderpath.This is the location where XML files are located you exported previously. This will typically be your local machine (NOT Exchange Server)

Browse to the script and enter the folder path where XML files are located

image 

To view which cmdlets are available enter:

Get-Command get-* -CommandType Function | ? {$_.module -eq $null}image
Execute any Exchange cmdlet
image

 

Limitations

  1. As all the data is generated using XML files no inbuilt Exchange Management Shell filtering is available, e.g: you cannot use –filter parameter but all native PowerShell filtering can be used.
  2. Any cmdlets which require user input during the export should be excluded until you want to provide an argument.
  3. Similar to Lync (get-cs*) Exchange does not provide a quick way to discover/display Exchange specific cmdlets , so some of the exported XML files and resulting output may contain non-Exchange cmdlets but this should not cause any issues.

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve this to prove you are not a bot * Time limit is exhausted. Please reload the CAPTCHA.

Post Navigation