15 July 2015

Whitespace report

With the help from Paul Cunningham's tutorial on how to send HTML formatted email with powershell, i threw together this small script to quickly get an overview of the available new mailbox database space, also know as "whitespace".

$Date = Get-Date
$smtpServer = "smtp.domain.lan"
$smtpFrom = "WhiteSpace@domain.nl"
$smtpTo = "receipient@domain.nl"
$messageSubject = "WhiteSpace report for $Date"

$message = New-Object System.Net.Mail.MailMessage $smtpfrom, $smtpto
$message.Subject = $messageSubject
$message.IsBodyHTML = $true

$a = "<style>"
$a = $a + "BODY{font-family: Arial; font-size: 10pt;}"
$a = $a + "TABLE{border: 1px solid black; border-collapse: collapse;}"
$a = $a + "TH{border: 1px solid black; background: #dddddd; padding: 5px;}"
$a = $a + "TD{border: 1px solid black; padding: 5px;}"
$a = $a + "</style>"

$message.Body = Get-MailboxDatabase -Status | sort name | select name,@{Name='DB Size (Gb)';Expression={$_.DatabaseSize.ToGb()}},@{Name='Available New Mbx Space Gb)';Expression={$_.AvailableNewMailboxSpace.ToGb()}} | ConvertTo-Html -Head $a

$smtp = New-Object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($message)

The result looks like this:

Run from the Task scheduler with this line:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\Bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; 'C:\_Scripts\Exchange\WhiteSpace.ps1'"

13 July 2015

Exchange 2013 OWA blank page error 400

If you encounter this problem (bad request, http 400 error) on your Exchange 2013 infrastructure.
These are the steps that you can follow to fix it.
Note:The powershell scripts are not mentioned anywhere in the official Technet documentation.
The powershell scripts are only mentioned on several blogposts regarding Microsoft Exchange 2010.
  1. Login to your Exchange 2013 CAS server
  2. Start the Exchange Management Shell
  3. Navigate to your Exchange 2013 binaries location, for example:C:\Program Files\Microsoft\Exchange Server\V15\Bin\
  4. Execute the UpdateCas.ps1 Windows PowerShell script and wait a few moments.
    This script will rebuild your OWA interface.
  5. If you haven’t executed UpdateConfigFiles.ps1 , now is a good time. Execute it.
    It looks like you need to execute this Windows PowerShell script, after each cumulative update of Microsoft Exchange 2013 to keep everything working smooth.

Conclusion
After each installation of a cumulative update for Exchange 2013, remember to execute both the UpdateCas.ps1 and UpdateConfigFiles.ps1 Windows PowerShell scripts.
It will save you a lot of trouble, troubleshooting errors with OWA and ECP.

06 July 2015

Restart all exchange 2013 services

Need to restart all Exchange 2013 services?

Restart the "Microsoft Exchange Active Directory Topology" service and all Exchange related services will restart.



Or do the same in Powershell:

Restart-Service MSExchangeADTopology

02 July 2015

Hide your internal server names from email header

When sending email to an organization outside your lan you also send some information that you don't want to expose and even in some cases those emails are not accepted because the SPF rules state that no local domain names are accepted, as they cannot be resolved by reverse DNS checking the HELO.

One way of dealing with this issue is to remove the anonymous access right on the send connector:

Get-SendConnector “Connector Name” | Remove-ADPermission -AccessRight ExtendedRight -ExtendedRights ms-Exch-Send-Headers-Routing -user “NT AUTHORITY\Anonymous Logon”


In my opinion there's an easier way, one that can be rolled back instantly in case something goes wrong or causes errors.
Create a Transport rule that removes the "header" from all out going messages.


Open Microsoft Exchange Console
Navigate to:
Microsoft Exchange \ Organization Configuration \ Hub Transport \ Transport Rules





  • Right Click and select New Transport Rule 
  • Name it " Remove headers "Received" ” 
  • click Next
  • Choose "From users inside or outside the organization"
  • Select Inside click Next
  • Choose Remove header
  • As message header just write: "Received"
  • Click Next twice