Memorise

Cannot send large messages via ActiveSync, iPhone/iPad

SYMPTOMS

When sending from a Mobile device via the ActiveSync service the device fails to send.

Some devices may return an error indicating that “The message that was sent to the server was rejected because the message was too large”. (Apple iPad iOS). Not all mobile devices behave this way and may just keep the message in the outbox folder and retried until removed from the folder.

CAUSE

Ther are number of reasons, couple of them listed below.

CAUSE 1

First one I have found is ActiveSync limit set to 10MB (%ExchangeInstallPath%ClientAccess\Sync\web.config maxRequestLength=”10240″)

CAUSE 2

A global IIS restriction preventing uploads larger than 49152 Bytes.

IIS 7.5 sets a default value of 49152 Bytes for the “UploadReadAheadSize” value which limits the amount of bytes allowed in the entity body of a request and the number of bytes a Web server will read into a buffer and pass to an ISAPI extension.

Diagnosis:

  • Navigate within IIS to the “Sites” node.
  • Determine the ID for the “MailEnable Protocols” website
  • Next navigate to the IIS log files path: C:\inetpub\logs\LogFiles
  • Locate the W3SVC(ID) folder, where ID is the number of the website ID above in step 2.
  • Sort the log files by “Date Modified’ and then open the latest log files in respect to the date/time you sent the message from the mobile device.
  • Search for lines like the examples below:

2020-03-27 20:33:38 192.168.0.1 POST /Microsoft-Server-ActiveSync User=test@myenroutetest.it&DeviceId=ApplDMRL2W3PF169&DeviceType=iPad&Cmd=SmartForward 443 – 192.168.0.2 Apple-iPad3C4/1102.55400001 413 0 0 6396

2020-03-27 20:33:38 192.168.0.1 POST /Microsoft-Server-ActiveSync User=test@myenroutetest.it&DeviceId=ApplDMRL2W3PF169&DeviceType=iPad&Cmd=SendMail 443 – 1921.68.0.2 Apple-iPad3C4/1102.55400001 413 0 0 6396

The above log snippets report a 413 error in the line which indicates the “Request Entity is too large”.

CAUSE 3

Incorrect authentication settings in Exchange Server Virtual Directory.

RESOLUTION – 1

Change the limit set on web.config, note this settings below for Frontend backed servers with different CAS and Mailbox server. For single server web.config is located in

C:\Program Files\Microsoft\Exchange Server\v14\ClientAccess\Sync\web.config has the following lines of code:

<system.web>
                         <!– Allow maximum 10 megs of content –>
                         <httpRuntime madRequestLength=”10240″ />

v14 is different verions of Exchange.

ActiveSync

Server roleConfiguration fileKeys and default valuesSize
Client Access%ExchangeInstallPath%FrontEnd\HttpProxy\Sync\web.configmaxAllowedContentLength="30000000 bytes"   Not present by default (see comments).bytes
Client Access%ExchangeInstallPath%FrontEnd\HttpProxy\Sync\web.configmaxRequestLength="10240"kilobytes
Mailbox%ExchangeInstallPath%ClientAccess\Sync\web.configmaxAllowedContentLength="30000000 bytes"   Not present by default (see comments).bytes
Mailbox%ExchangeInstallPath%ClientAccess\Sync\web.configmaxRequestLength="10240"kilobytes
Mailbox%ExchangeInstallPath%ClientAccess\Sync\web.config<add key="MaxDocumentDataSize" value="10240000">bytes

Comments on ActiveSync limits

By default, there is no maxAllowedContentLength key in the web.config files for ActiveSync. However, the maximum message size for ActiveSync is affected by the maxAllowedContentLength value that is applied to all web sites on the server. The default value is 30000000 bytes (30 MB). To see these values for ActiveSync on Client Access Servers and Mailbox servers in IIS Manager, perform the following steps:

  1. Do one of the following steps:
    • On Client Access servers, open IIS Manager, navigate to Sites > Default Web Site and select Microsoft-Server-ActiveSync.
    • On Mailbox servers, open IIS Manager, navigate to Sites > Exchange Back End and select Microsoft-Server-ActiveSync.
  2. Verify Features View is selected, and double-click Configuration Editor in the Management section.
  3. Click the dropdown arrow in the Section field, navigate to system.webServer > security and select requestFiltering.
  4. In the results, expand requestLimits, and you’ll see maxAllowedContentLength and the default value 30000000 (bytes).

To change the maxAllowedContentLength value, enter a new value in bytes, and click Apply. You need to change the value on Client Access servers and on Mailbox servers. After you change the value in IIS Manager, a new maxAllowedContentLength key is written to the corresponding web.config file (%ExchangeInstallPath%FrontEnd\HttpProxy\Sync\web.config on Client Access servers, and %ExchangeInstallPath%ClientAccess\Sync\web.config on Mailbox servers).

To change the maximum message size for ActiveSync clients, you need to change the value of maxRequestLength in the web.config file on Client Access servers and Mailbox servers, MaxDocumentDataSize in the web.config file on Mailbox servers, and maxAllowedContentLength in IIS Manager on Client Access servers and Mailbox servers.

  • RESOLUTION – 2
  • Open a Windows command prompt with administrator rights and navigate to the following location: C:\inetpub\AdminScripts
  • Run the following command: cscript adsutil.vbs set w3svc/14/uploadreadaheadsize 51200000

Where “14” in the above command is the website ID

RESOLUTION – 3

Check the virtual directory authentication settings in the Exchange server for
EWS (Default Web Site), it should be
Integrated windows authentication only and for

Microsoft-Server-ActiveSync (Default Web Site) authentication set to
Basic authentication and ignore client certificate


Enable Automatic Replies, Out Of Office, for another user or additional mailbox

Admin Method 1: Exchange PowerShell

Exchange PowerShell button

If you are an Exchange administrator, then using the Set-MailboxAutoReplyConfiguration Exchange PowerShell command is the supported and native way to go to enable Automatic Replies without logging on to the mailbox itself.

Set-MailboxAutoReplyConfiguration -Identity <username> -AutoReplyState Enabled -InternalMessage "Internal auto-reply message." -ExternalMessage "External auto-reply message."

Admin Method 2: Exchange Admin Center

Exchange Admin Center button

Another way to do this as an Exchange Administrator is via the Exchange Admin Center (also known as ECP).

  1. Logon to the Exchange Admin Center.
  2. Change the management scope;
    • Exchange 2010
      In the top left corner, next to Mail> Options, click on: Manage My Organization
    • Exchange 2013, Exchange 2016, Exchange 2019 and Office 365 Exchange Online
      Click on your name or image in the top right corner.
  3. Choose: Another user…
  4. Select the user that you want to manage.
  5. In the page that opens, you can now set up an automatic reply message (in Exchange 2010: Tell people you’re on vacation).

Xerox Scan to email

C405 Set up scan to email 

So onto the printer side. Open the webpage to configure the device (Enhanced web Service, shortened from here on as EWS)

EWS > Connectivity > SMTP

undefined

Which will show you this (normally I would pre-fill this with your settings, but since I don’t know your settings because of your SMTP server not showing them on its website, I’m using GMAIL as my example.

undefined

Basically:

1. Device Email and SMTP AUTH user name have to match

2. The 2 password boxes are pretty self-evident.

3. Validation Type absolutley needs to be set to On Device

4. SMTP server address is whatever Media Temple says to use from the link above, the port number too, and the Connection Security (maybe called Encryption) too.

Of course the SMTP server name can be the IP address or the hostname of the server, but to use the hostname, you have to make sure DNS is correct on the printer EWS > Connectivity > Ethernet > DNS > Edit

undefined

And if HTTPS is enabled on the printer, or SSL/TLS/STARTTLS is being used for Encryption, then the time must be correct to within 3 minutes EWS > System > Date& Time

undefined

If you set it up correctly and get odd faults (017-714 for instance, try updating the firmware, the launch firmware has issues with SHA-2), you can get the latest firmware right here


Office365 SMTP

Office 365 SMTP server settings

Server: smtp.office365.com

Alternative server: outlook.office365.com

Port: 587

Encryption: TSL

Authentication: Yes – use your full username and password.

Note: Sending emails also works if TCP 25 is set as a port in connection settings, but using TCP 587 is recommended.

Office 365 POP3 settings

Server: outlook.office365.com

Port: 995

Encryption: TSL

Authentication: Yes – use your full username and password.

Office 365 IMAP settings

Server: outlook.office365.com

Port: 993

Encryption: SSL

Authentication: Yes – use your full username and password.

» Email sending

To send emails using Office365 server enter these details:

SMTP Host: smtp.office365.com
SMTP Port: 587
SSL Protocol: OFF
TLS Protocol: ON
SMTP Username: (your Office365 username)
SMTP Password: (your Office365 password)

Also make sure that your:

  1. “From” email in HESK settings (General tab) is set to your Office365 email address
  2. “From” name in HESK settings (General tab) is NOT set to an email address – Microsoft security policies will reject sending emails if the From name is an email address

» POP3 fetching

To fetch mail from Office365 server enter these details:

POP3 Host: outlook.office365.com
POP3 Port: 995
TLS Protocol: ON
POP3 Username: (your Office365 username)
POP3 Password: (your Office365 password)

» IMAP fetching

To fetch mail from Office365 server using IMAP protocol instead, enter these details:

IMAP Host: outlook.office365.com
IMAP Port: 993
Encryption: SSL
IMAP Username: (your Office365 username)
IMAP Password: (your Office365 password)

» Error messages

Connection timed out
Could not connect to…
Testing connection, this can take a while… 

This usually means required ports are blocked on your server in the firewall.

Contact your hosting company to verify and ask them to unblock required ports (587, 995 and/or 993) to allow TCP connections.
 

Password error: Logon failure: unknown user name or bad password.
Too many login failures

Office365 doesn’t recognize your username or your password is incorrect. Double-check both the username and password. Passwords are CaSe SeNSiTiVe.

554 5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied

Make sure the “From” email (HESK settings > General tab) is set to the SMTP email address and that the “From” name is NOT set to an email address.


Remove an old RDS from Server Pool (2012 R2)

First you have to install SQL Server Management studio on your RDS management/licensing server/all of your RDS connection brokers (if your have more than one, follow the below steps, rinse and repeat…):
https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-2017

Open up SSMS RUN AS ADMINISTRATOR and connect here:\\.\pipe\MICROSOFT##WID\tsql\query

Open a query window, run this query:

SELECT TOP 1000 [Id],[Name] FROM [RDCms].[rds].[Server]

Look at the list of servers in the NAME column. Find your dead server and note the ID number in the ID column. For this example, lets say my id is “5”. The ID for your system will most likely be different so don’t just copy and paste the below commands, make sure you change the ID to what you actually need to remove.

—-MAKE SURE YOU HAVE A DATABASE BACKUP OR SYSTEM CHECKPOINT OR SYSTEM BACKUP OR SOMETHING BEFORE PROCEEDING—-

Run the following query to remove the dead SESSION HOST server from the database:

use RDCms;
delete from rds.RoleRdsh where ServerID = ‘5’;

I also needed to remove the server from the rds.Server table:

use RDCms;
delete from rds.Server where Id = ‘5’;

Note, the above covers the session host role. If you have a server with other roles there are other tables you can look at and delete by id. Just right-click on the table (after drilling down in object explorer in to the RDCms database) and “Select Top 1000 rows” to see if your server ID is listed there.

Relevant tables:
rds.RoleRdcb (Connection Broker)
rds.RoleRdls (License Server)
rds.RoleRdsh (Session Host)
rds.RoleRdvh (Virtualisation Host)
rds.RoleRdwa (Web Access Host)

You can use the following powershell command from an elevated powershell prompt (before and after to confirm the server is gone) to list out RDS servers:get-RDServer

Conclusion:
Once everything is deleted out of the DB, close SSMS and then close and re-open Server Manager. Now you can get to your Remote Desktop Services management screen and get on with your life!


MS Exchange email won’t download on iPhone

I can’t seem to download emails on my iPhone, can sign into OWA and get it working on any version on Outlook, but it won’t download email on iPhone.

I’m able to successfully configure the email on phone but when I go into the mail app, and try to download the emails, I get an error “the connection to the server failed”.

FIX: Issue was the DCs weren’t replicating. Once I forced it to replicate in Sites and Services, emails started coming in automatically.


Juniper Keyboard Sequences to Move Around and Edit the Junos OS CLI

Table 1: CLI Keyboard Shortcuts

Keyboard sequenceAction
Ctrl+bMove the cursor back one character.
Esc+b or Alt+bMove the cursor back one word.
Ctrl+fMove the cursor forward one character.
Esc+f or Alt+fMove the cursor forward one word.
Ctrl+aMove the cursor to the beginning of the command line.
Ctrl+eMove the cursor to the end of the command line.
Ctrl+h, Delete, or BackspaceDelete the character before the cursor.
Ctrl+dDelete the character at the cursor.
Ctrl+kDelete the all characters from the cursor to the end of the command line.
Ctrl+u or Ctrl+xDelete the all characters from the command line.
Ctrl+w, Esc+Backspace, or Alt+BackspaceDelete the word before the cursor.
Esc+d or Alt+dDelete the word after the cursor.
Ctrl+yInsert the most recently deleted text at the cursor.
Ctrl+lRedraw the current line.
Ctrl+pScroll backward through the list of recently executed commands.
Ctrl+nScroll forward through the list of recently executed commands.
Ctrl+rSearch the CLI history incrementally in reverse order for lines matching the search string.
Esc+/ or Alt+/Search the CLI history for words for which the current word is a prefix.
Esc+. or Alt+Scroll backward through the list of recently entered words in a command line.
Esc+number sequence or Alt+number sequenceSpecify the number of times to execute a keyboard sequence.

Exchange PST Export

Before you can export PST you will need to have mailbox Import/Export role

Add to Mailbox Import Export role

New-ManagementRoleAssignment -Role “Mailbox Import Export” -User “<user name or alias>”

Now you can use the command below to export pst

New-MailboxExportRequest -Mailbox <user> -FilePath \\<server FQDN>\<shared folder name>\<PST name>.pst

 

I have multiple organisation, therefore I need to specify the Domain controller where the users exist.

EXPORT PST

New-MailboxExportRequest -DomainController glob-dc01.sal.dom.ab-org.co.uk -Mailbox shiraj@shiraj.co.uk -FilePath “\\192.168.140.99\ExportPst\Shiraj042019.pst”

Get-MailboxExportRequest

Get-MailboxExportRequest -Mailbox “<MailboxIdentity>” | Format-List Name,FilePath,Mailbox,Status

Get-MailboxExportRequestStatistics -Identity “<MailboxIdentity>\<MailboxExportRequestName>”

EXAMPLE:

[PS] C:\Exchange_Scripts>Get-MailboxExportRequest -Mailbox “shiraj@shiraj.co.uk” | Format-List Name,FilePath,Mailbox,Status

Name : MailboxExport
FilePath : \\192.168.140.99\ExportPst\Shiraj042019.pst
Mailbox : sal.dom.ab-org.co.uk/SAL/Users/Shiraj
Status : InProgress

[PS] C:\Exchange_Scripts>Get-MailboxExportRequestStatistics -Identity “shiraj@shiraj.co.uk\MailboxExport”

Name                                   StatusDetail                          SourceAlias             PercentComplete
—-                                       ————                              ———–                  —————
MailboxExport                 CopyingMessages                 Sshiraj                       82

[PS] C:\Exchange_Scripts>


Get All Users Outlook/Inbox Rules in Office 365

Get All Users Outlook/Inbox Rules in Office 365

Description:  PowerShell cmdlet to view inbox rules is Get-InboxRule. First grab all mailboxes in the organisation and store the UserPrincipalName in a variable.  Here we are storing it in a variable called “Users”

Then for each user we are going to get the InboxRule and select several attributes:

  • MailboxOwnerID
  • Name
  • Description
  • Enabled
  • RedirectTo
  • MoveToFolder
  • ForwardTo

The entire list of attributes we can grab per mailbox is:

  • Enabled
  • Identity
  • InError
  • ErrorType
  • Name
  • Priority
  • RuleIdentity
  • SupportedByTask
  • Legacy
  • BodyContainsWords
  • ExceptIfBodyContainsWords
  • FlaggedForAction
  • ExceptIfFlaggedForAction
  • FromAddressContainsWords
  • ExceptIfFromAddressContainsWords
  • From
  • ExceptIfFrom
  • HasAttachment
  • ExceptIfHasAttachment
  • HasClassification
  • ExceptIfHasClassification
  • HeaderContainsWords
  • ExceptIfHeaderContainsWords
  • FromSubscription
  • ExceptIfFromSubscription
  • MessageTypeMatches
  • ExceptIfMessageTypeMatches
  • MyNameInCcBox
  • ExceptIfMyNameInCcBox
  • MyNameInToBox
  • ExceptIfMyNameInToBox
  • MyNameInToOrCcBox
  • ExceptIfMyNameInToOrCcBox
  • MyNameNotInToBox
  • ExceptIfMyNameNotInToBox
  • ReceivedAfterDate
  • ExceptIfReceivedAfterDate
  • ReceivedBeforeDate
  • ExceptIfReceivedBeforeDate
  • RecipientAddressContainsWords
  • ExceptIfRecipientAddressContainsWords
  • SentOnlyToMe
  • ExceptIfSentOnlyToMe
  • SentTo
  • ExceptIfSentTo
  • SubjectContainsWords
  • ExceptIfSubjectContainsWords
  • SubjectOrBodyContainsWords
  • ExceptIfSubjectOrBodyContainsWords
  • WithImportance
  • ExceptIfWithImportance
  • WithinSizeRangeMaximum
  • ExceptIfWithinSizeRangeMaximum
  • WithinSizeRangeMinimum
  • ExceptIfWithinSizeRangeMinimum
  • WithSensitivity
  • ExceptIfWithSensitivity
  • ApplyCategory
  • ApplySystemCategory
  • CopyToFolder
  • DeleteMessage
  • DeleteSystemCategory
  • ForwardAsAttachmentTo
  • ForwardTo
  • MarkAsRead
  • MarkImportance
  • MoveToFolder
  • PinMessage
  • RedirectTo
  • SendTextMessageNotificationTo
  • StopProcessingRules
  • MailboxOwnerId
  • IsValid
  • ObjectState
  • RunspaceId
  • Description

Finally, export the information to a CSV. The -Append parameter is necessary so it doesn’t overwrite the csv file as it moves onto the next mailbox.

PowerShell Script :