Increase signature field length in Exchange 2010 OWA with PowerShell

We recently ran into a problem with changing the mail signature of a client that the new signature that he wanted was simply to long for Outlook Web App to handle by default. After a long search on the web we found a great link that helped us with the problem and got it resolved.

However we wanted and needed to do this as a script so that with an Exchange update we could retain the new field size. So with some help I created a simple script that allows you to set the signature field length to whatever you want.

Keep in mind that the default value before you start editing is 4000. This way you can always return to the default if you require it.

Feedback is of course always welcome and I will try to implement them. This post is here for people that need help with figuring this whole thing out. The script is very simple to just do the job it is meant to do.

<#
.SYNOPSIS
This is a simple Powershell script to allow you to easily change the maximum signature length on Exchange 2010, OWA. The default value for Length is 4000.

.DESCRIPTION
The script will find the standard path it needs if not path is specified. Then using regex replaces the MaxLength property with the Length input and saves the file on the same location

.EXAMPLE
Set-OWASignatureLength -Length 4000
This example sets the default value of 4000 in the file without using the Path property so it finds and searches it instead

.EXAMPLE
Set-OWASignatureLength -Length 12000 -Path "C:\Program Files\Microsoft\Exchange Server\V14\ClientAccess\ecp\Customize\EMailSignature.ascx"
This example sets the default value of 12000 in the file and using the Path property

.LINK 
https://perplexity.nl
Increase Exchange 2010 OWA Signature Field
#>


[CmdletBinding()]
param
(
    [Parameter(Mandatory=$true)][int]$Length = 4000,
    [string]$Path
)

Write-Verbose "Checking requirements for the change"

if (-Not($Path))
{
    if (Test-Path("C:\Program Files\Microsoft\Exchange Server\V14\ClientAccess\ecp\Customize\EMailSignature.ascx"))
    {
        $Path = "C:\Program Files\Microsoft\Exchange Server\V14\ClientAccess\ecp\Customize\EMailSignature.ascx"
    }
}

if (-Not($Path))
{
    Write-Error -Message "The required file that needs to be changed is not found"
    Exit
}

Write-Verbose "Loading in $Path"
$Input = Get-Content $Path

Write-Verbose "Replacing the text with defined Length"
$OutputText = 'MaxLength="' + $Length + '"'
$Output = $Input -replace 'MaxLength="(.*?)"', $OutputText

Write-Verbose "Saving output file to $Path"
$Output | Out-File $Path

Leave a Comment