Customize the Outlook Web App Logon Page

Microsoft has provided some basic details on how to customize the Outlook Web App logon page (OWA) in Exchange 2013.  I’ve taken things a bit further and modified logon.aspx and logon.css to customize the OWA logon page with a PowerShell script.

It is important to note that at this time the script does not back up any of the files that it modifies.  Be warned, you should backup logon.aspx and logon.css.  As of Exchange 2013 SP1 CU6 they are located in the following directories:

Logon.aspx:  C:\Program Files\Microsoft\Exchange Server\V15\FrontEnd\HttpProxy\owa\auth

Logon.css:  C:\Program Files\Microsoft\Exchange Server\V15\FrontEnd\HttpProxy\owa\auth\15.0.995\themes\resources

The first section between lines 1-11 I am setting the path to all the locations we’ll need to modify. On line 11 I’m dumping the contents of logon.aspx into a variable in order to customize it.

Line 13-24 handles the creation of a disclaimer.  I’ve used mostly silly words in there but a few things are noteworthy.  The encapsulation of the text within @” and “@  preserves the formatting as written in the script.  I’ve also created a div class called disclaimer that will be referenced and formatted within Logon.css.  There are HTML <BR> to make spacing in the paragraphs for emphasis.  Use this as you see fit.

Lines 31-51 handle the additions to Logon.css that will be used later in the script.  Here I’m setting the font, color to match the rest of OWA and created a margin so the text isn’t on top of the logon elements in the web page.  Since OWA is modern it accounts for tablet views defined with twide and tnarrow.  These required some trial and error margin settings that keep spacing between elements on the page.

I’m using an If statement against the contents of Logon.aspx to see if has been modified with the text “Outlook Web App” as that appears in the disclaimer.  If it isn’t there then lines 61-73 handles the customization.  Initially I used a hard coded line number to in order to add the disclaimer but once I installed CU6 the length of Logon.aspx changed and the script broke my OWA logon page. My solution for this was to search for “hidden-submit” and record the line number and select all the text from the beginning up to the line I just noted.  Then I had to get the total number of lines and compute how many lines occurred after “hidden-submit”.

Line 67 handles taking the first chunk, the disclaimer, and finally the last chunk and putting it all together to create the custom Logon.aspx

Lines 75-91 create the customization of Logon.css and simply adds lines to the end of the file with one exception.  Line 88 replaces the min-height value of 650 pixels with a value of 700 pixels.  This is important so that the blue field on the left side of the window extends just below the disclaimer text.  You’ll need to adjust that min-height value according to the amount of disclaimer text you insert.

Customize the Outlook Web App Logon Page
Custom OWA with disclaimer in IE

This customization also displays the disclaimer on mobile devices as seen in the screenshot below:

Custom OWA viewed on Iphone


# Set the OWA Path sub-directory using $EXInstall variable.
$OWAPath = $EXInstall + "FrontEnd\HttpProxy\owa"
# Set the OWA version path sub-directory using the $OWAPath variable.
$OWAPathVersion = $OWAPath +"\auth\"
# Set the LogonASPX variable to the logon.aspx file using the $OWAPath variable.
$LogonASPXPath = $OWAPath + "\auth\logon.aspx"
# Select the lastest OWA version folder.
$OWAVersion = Get-ChildItem $OWAPathVersion -Name "15.*" | `
Sort-Object -Descending LastWriteTime | Select-Object -First 1
# Get the contents of the logon.aspx file.
$LogonASPX = Get-Content -Path ($OWAPathVersion + "\logon.aspx")
# The disclaimer text to add contained within a div class named disclaimer.
$InjectDisclaimer =@"
        <div class="disclaimer">You are accessing a private information
        system, which includes this computer, and all Exchange 2013 DAG
        databases, including the FrontEnd HttpProxy. This information is
        provided for private use only. Improper use of this PowerShell
        script may result in a broken Outlook Web App logon page.<br><br>
        By using this script, you understand the following: <br>
        You are soley responsible for all changes made when using this
        PowerShell script to customize the Outlook Web App logon page. The
        disclaimer continues on and will become repetitive at some point.
        Please continue reading this as it is important to the customization
        of Outlook Web App and Exchange 2013. Additionally you should
        understand that (1) Squeaky Lobsters are important to Exchange Server
        lore, (2) Cloud Cloud Cloud, (3) Exchange 2013 is cool.
# Create the disclaimer text modifications for font and spacing.
$InjectCSS = @"
    font-family:'Segoe UI WPC','Segoe UI',Tahoma,'Microsoft Sans Serif',Verdana,sans-serif;
.tnarrow .disclaimer
.twide .disclaimer
# Use an If statement to determine if logon.aspx contains disclaimer text.
If ($LogonASPX | Select-String -pattern "Outlook Web App"){
    # Notify the console that the disclaimer has been added to logon.aspx
    Write-Host "Logon.aspx is modified with the disclaimer" -ForegroundColor Green
} else {
    # Notify the console that the disclaimer has NOT been added to logon.aspx
    Write-Host "Logon.aspx is not yet modified with the disclaimer. Writing Changes" -ForegroundColor Yellow
    # Reference "hidden submit" to determine disclaimer location within logon.aspx
    $Insertline = ($LogonAspx | select-string "hidden-submit").LineNumber
    # Select all text from beginning of file to the line noted in $Insertline variable.
    $OrigFirstLogonAspx = $LogonASPX | Select-Object -first $Insertline
    # Determine the number of lines contained in logon.aspx
    $LastLine = ($LogonASPX | Measure-Object).count
    # Compute the number of lines after the hidden submit reference point and select that text.
    $OrigLastLogonAspx = $LogonASPX | Select-Object -Last ($LastLine - ($Insertline + 1))
    # Put the three variables together for the modified logon.aspx
    $LogonAspxMod = $OrigFirstLogonAspx + $InjectDisclaimer + $OrigLastLogonAspx
    # Overwrite logon.aspx with the modifications.
    Set-Content -Path ($OWAPathVersion + "\logon.aspx") -Value $LogonAspxMod
# Get the contents of logon.css
$OrigLogonCSS = Get-Content -Path ($OWAPathVersion + $OWAVersion + "\themes\resources\logon.css")
# Use an If statement to determine if logon.css contains disclaimer modifications.
If ($OrigLogonCSS | Select-String -Pattern "disclaimer"){
    # Notify the console that the disclaimer has been added to logon.css
    Write-Host "Logon.css is modified for disclaimer changes" -ForegroundColor Green
} else {
    # Notify the console that the disclaimer has NOT been added to logon.css
    Write-Host "Logon.css is not yet modified for disclaimer. Writing changes." -ForegroundColor Yellow
    # Add the modifications to the end of logon.css text.
    $LogonCSSMod = $OrigLogonCSS + $InjectCSS
    # Replace the min-height value so that the sidebar matches the longer length of the disclaimer text.
    $LogonCSSMod = $LogonCSSMod -replace 'min-height: 650px;','min-height: 700px;'
    # OverWrite the logon.css with the logon.css text modifications.
    Set-Content -Path ($OWAPathVersion + $OWAVersion + "\themes\resources\logon.css") -Value $LogonCSSMod


2 thoughts on “Customize the Outlook Web App Logon Page”

Leave a Comment