Use MFCMapi to locate the Categories used in your mailbox

Scenario:  After mailbox categories have mysteriously disappeared, you want to verify that the categories are not hanging around in the backend of your mailbox.  The concern is that you re-add the categories and if they mysteriously show up, it would create a headache to clean it up.

Solution: The categories that is used throughout the mailbox is located in a hidden area in the calendar. Using MFCMapi, navigate to the PR_ROAMING_XMLSTREAM by following:

  1. Session –>Logon
  2. Select the mailbox profile for the user affected.
  3. Expand Top of Information Store
  4. Right click on Calendar and select ‘Open Associated Contents Table’
  5. Select the entry with Subject  “IPM.Configuration.CategoryList”
  6. Locate and open the property “PR_ROAMING_XMLSTREAM”
  7. Copy the contents of the Text value into notepad and parse everything that starts with <category name =”…”
  8. Now you can see a list of every category that is associated with the mailbox.

 

Powershell: Increase the max size limit for ActiveSync Properties/Metadata in you Web.Config

Scenario:  You need to increase the ActiveSync default message size limit from 10MB to a larger value.  By default the RequestFilteringLimit set in IIS is 30,000,000 bytes (approx. 28MB) so we will operate within the limitations of that setting, meaning you cannot go higher than 28MB unless you set that property to a higher value.  So lets be safe and set that value to 15MB on all multirole exchange 2013 servers.  We need to edit the web.config files in the following directories:
Client Access: 

%ExchangeInstallPath%FrontEndHttpProxySyncweb.config – maxRequestLength=”10240″ kilobytes

Mailbox

%ExchangeInstallPath%ClientAccessSyncweb.config – maxRequestLength=”10240″ kilobytes

%ExchangeInstallPath%ClientAccessSyncweb.config  – <add key=”MaxDocumentDataSize” value=”10240000″>  bytes
Script:  IISReset is not needed!

#variables
$servers = (Get-ExchangeServer).name
$MRL = "15360"  #15MB in KB
$MDDS = "15728640" #15MB in Bytes


$Servers | %{
#ClientAccess
    #MaxRequestLength
    $webConfig = "\$_c$Program FilesMicrosoftExchange ServerV15FrontEndHttpProxysyncweb.config" 
    $doc = new-object System.Xml.XmlDocument 
    $doc.Load($webConfig) 
    $doc.get_DocumentElement()."system.web".httpruntime.maxrequestlength = $MRL 
    #Save Document
    $doc.Save($webConfig) 

#Mailbox
    #MaxRequestLength
    $webConfig = "\$_c$Program FilesMicrosoftExchange ServerV15ClientAccessSyncweb.config" 
    $doc = new-object System.Xml.XmlDocument 
    $doc.Load($webConfig) 
    $doc.get_DocumentElement()."system.web".httpruntime.maxrequestlength = $MRL 
    #MaxDocumentDataSize
    $key = "MaxDocumentDataSize"
    $node = $doc.SelectSingleNode('configuration/appSettings/add[@key="' + $key + '"]') 
    $node.Attributes['value'].Value = $MDDS 
    #Save Document
    $doc.Save($webConfig) 
}

 

 

EWS Script: Create a Folder in a Mailbox

Scenario:  You want to use EWS to create a folder in a mailbox.

Script:

###Load the EWS Assembly
    Import-Module -Name "C:Program FilesMicrosoftExchange ServerV15BinMicrosoft.Exchange.WebServices.dll"

    $service = new-object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.Exchangeversion]::exchange2013)

    $service.Url = new-object System.Uri("https://mail.domain.com/EWS/Exchange.asmx")

###Pick the Mailbox
$mailboxname = "steve@mail.com"

#Creates a Folder 
    $NewFolder = new-object Microsoft.Exchange.WebServices.Data.Folder($service)
    $NewFolder.DisplayName = "Archive123"


#Save the folder under the Inbox
    $folderidInbox = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox,$MailboxName)
    $NewFolder.Save($folderidInbox)

    #--OR--#

    #Save that folder on the Root
    $RootFolderId = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::MsgFolderRoot,$mailboxname)   
    $NewFolder.Save($RootFolderID)

Federated Trust for Hybrid Environment

Add a Federated Trust using powershell for a Hybrid Environment

 

-Production on-premies powershell

PS H:> Get-FederationInformation -DomainName Friendly.onmicrosoft.com -BypassAdditionalDomainValidation | New-OrganizationRelationship “Friendly Online” -FreeBusyAccessEnabled $true -FreeBusyAccessLevel AvailabilityOnly

 

-Production cloud powershell

PS H:> Get-FederationInformation -DomainName Friendly .onmicrosoft.com -BypassAdditionalDomainValidation | New-OrganizationRelationship “Friendly Online” -FreeBusyAccessEnabled $true -FreeBusyAccessLevel AvailabilityOnly

 

-From outside company powershell

PS H:> New-OrganizationRelationship -Name “your company” -DomainNames “your company”.mail.onmicrosoft.com, “your company”.onmicrosoft.com,”Your company”.edu -FreeBusyAccessEnabled $true -FreeBusyAccessLevel AvailabilityOnly -TargetApplicationUri outlook.com -TargetAutodiscoverEpr https://autodiscover-s.outlook.com/autodiscover/autodiscover.svc/WSSecurity -Enabled $true

 *NOTE: cloud to cloud free busy search you will have to use the target addresses e.g someone@company.mail,onmicrosoft.com

 

EWS Script: Move email items based on received date into a folder

Scenario:  You want to move email items based on date range into a folder.

Script:  The script performs the following:

  1. Attaches to the mailbox specified in the script
  2. Looks in the inbox for email items with a received that lies between a date range.
  3. Creates a folder
  4. Moves those items into that folder.
#Make sure the account you run this as has full access permissions to the mailbox

#Load the EWS Assembly
    Import-Module -Name "C:Program FilesMicrosoftExchange ServerV15BinMicrosoft.Exchange.WebServices.dll"

    $service = new-object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.Exchangeversion]::exchange2013)

    $service.Url = new-object System.Uri("https://Ex2013Srv1/EWS/Exchange.asmx")


#Define your Variables
    #$StartDate = [system.DateTime]::Today.AddDays(-1)
    #$EndDate = [system.DateTime]::Today
    #OR
    [datetime]$StartDate  = "11/17/2015"
    [datetime]$EndDate = "11/18/2015"
    $mailboxname = "steve@domain.com"

#Bind your Folder & Create your filter
    $folderid = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox,$MailboxName)
    $InboxFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folderid)
    $Sfgt = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+IsGreaterThan([Microsoft.Exchange.WebServices.Data.ItemSchema]::DateTimeReceived, $StartDate)
    $Sflt = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+IsLessThan([Microsoft.Exchange.WebServices.Data.ItemSchema]::DateTimeReceived, $EndDate)


#Create Collection and Apply your Filter
    $sfCollection = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+SearchFilterCollection([Microsoft.Exchange.WebServices.Data.LogicalOperator]::And);
    $sfCollection.add($Sfgt)
    $sfCollection.add($Sflt)
    $view = new-object Microsoft.Exchange.WebServices.Data.ItemView(2000)
    $frFolderResult = $InboxFolder.FindItems($sfCollection,$view)


#Creates a Folder
    $NewFolder = new-object Microsoft.Exchange.WebServices.Data.Folder($service)
    $NewFolder.DisplayName = $EndDate.ToString("yyyy-MM-dd")
    $NewFolder.Save($InboxFolder.Id.UniqueId)


#Moves your Email Items
    foreach ($miMailItems in $frFolderResult.Items){
    "Moving:" + $miMailItems.Subject.ToString()
    [VOID]$miMailItems.Move($NewFolder.Id)
    }

	

Detect Backpressure on your Exchange Servers

Scenario:  Customers are complaining about connectivity issues and degraded performance with their mail clients. You suspect its due to backpressure on a server, but you want to dig a little deeper.

Troubleshooting:

1.Check for Windows Event 2002 “The number of outstanding requests for guard TargetBackend has exceeded the max limit 150. Current request will be rejected” by running this PowerShell command:

Get-WinEvent -computername <remote computer> -FilterHashtable @{logname=’application’;id=2002}

 

2. Check the number of mounted copies of mounted Exchange Databases on each server and manually spread them out:

(get-mailboxdatabasecopystatus -server <remote computer> | Where status -like Mounted).count

3. Check for user counts and compare against each server by running this Powershell Command:

(Get-WmiObject Win32_LoggedOnUser -ComputerName <remote computer>| Select Antecedent -Unique).count

Mailbox server “Servername” is a member of cluster. The server must be evicted from the cluster prior to adding it to database availability group “DAGName”

Scenario:  You receive the following error when attempting to join a Mailbox server to a new DAG after removing the server from a old DAG:

Mailbox server “Servername” is a member of cluster. The server must be evicted from the cluster prior to adding it to database availability group “DAGName”

Solution:

Run Get-databaseavailabilitygroup and verify that the server is not a member of an existing DAG.  If it is, run the following:

remove-databaseavailabilitygroupserver <Servername>

You may have to use the –configurationonly switch if it doesn’t remove the server properly.

If that does not work,  remote into the server that is having the issue and run the following:

Remove-clusternode <servername>

Need to recreate Arbitration Mailboxes as they are no longer available

Scenario:  You have arbitration mailboxes that are located on databases that are no longer accessible.   Although the mailbox is no longer accessible, the AD User account is still in tact.

Solution:  Disable and re-enable the arbitration mailboxes.  The Database DB04 is where the arbitration mailboxes lived but DB04 is gone.

Set-adserversettings -viewentireforest:$true

$1 = get-mailbox -arbitration | Where Database -like DB04 

$1 | Disable-mailbox -confirm:$false

$1 | Enable-mailbox

The Error: Couldn’t disable the arbitration mailbox because it is associated with existing recipients for which membership restriction of approval is required or the moderation feature is enabled. Please disable the approval feature on those recipients before performing this operation.

Scenario:  You receive the following error when trying to disable/remove an arbitration mailbox:

Couldn’t disable the arbitration mailbox because it is associated with existing recipients for which membership restriction of approval is required or the moderation feature is enabled. Please disable the approval feature on those recipients before performing this operation.

Solution:  Locate the distribution groups that are using this arbitration mailbox.  You will be able to transfer the arbitration mailbox used by the distribution groups if you have another.

Get-distributiongroup  | Select Name, ArbitrationMailbox

OR

Get-distributionGroup | Where ArbitationMailbox -like “Domain.Com/Users/SystemMailbox{149831f20381-30d4-ed31-1345defe2313”

You can use the opposite to set it to the new Arbitation mailbox:

set-distributiongroup -identity “name of Distribution Group” -arbitrationmailbox “name of Arbitration Mailbox”