Set Email Signatures in Office 365 Exchange Online

Introduction

This script can set text and HTML email signatures to your outgoing email messages in Office 365 Exchange Online.

Scenarios 

Microsoft Outlook enables you to change email signatures very easily. However, this feature is difficult to use in Outlook Web App (OWA). For example, it may be difficult to insert images as signatures. Therefore, in order to set email signatures in OWA, you must find a workaround.

Prerequisites 

This script requires Exchange Web Service Managed API 2.0. Please download and install the package from Microsoft Download Center. This script cannot work correctly without this package. 

Script 

This script contains the following advanced functions: 
You can use this script in the following way.  
  1. Open Windows PowerShell.
  2. Run Import-Module cmdlet to import this
    module file.
    Import-Module filepath\scriptname.psm1
After running Set-OSCEXOEmailSignature, you may need to sign out and sign in OWA again to verify the changes. 
Here are some code snippets for your references. To get the complete script sample, please click the download button at the beginning of this page.
PowerShell
Edit|Remove
#Set HTML signature 
if (-not $owaUserOptions.Dictionary.ContainsKey("signaturehtml")) { 
    if (-not [System.String]::IsNullOrEmpty($HtmlSignature)) { 
        $owaUserOptions.Dictionary.Add("signaturehtml",$HtmlSignature) 
    } 
} else { 
    if (-not [System.String]::IsNullOrEmpty($HtmlSignature)) { 
        if ($Force) { 
            $owaUserOptions.Dictionary["signaturehtml"] = $HtmlSignature 
        } else { 
            $warningMsg = $Messages.ExistingHtmlSignature 
            $PSCmdlet.WriteWarning($warningMsg) 
        } 
    } else { 
        $owaUserOptions.Dictionary.Remove("signaturehtml"| Out-Null 
    } 
}
 

Examples

Example 1: How to display help about Set-OSCEXOEmailSignature
To display help about this function, please run this command.
Get-Help Set-OSCEXOEmailSignature -Full
 

Example 2: How to initiate a connection to Office 365 Exchange Online.
To initiate a connection to Office 365 Exchange Online, please run this command. You must run this example before
any other step.
Connect-OSCEXOWebService -Credential (Get-Credential admin@domain01.onmicrosoft.com)

Note
The Connect-OSCEXOWebService function creates a new variable called exService. This variable is in the global scope of the current Windows PowerShell session. This variable is used by other functions in the script.

Example 3: How to change the text signature for current user who established the connection to Office 365.
To change the text signature for current user who established the connection to Office 365, please run this command.
Set-OSCEXOEmailSignature -TextSignature (Get-Content C:\Scripts\051\textsignature.txt | Out-String) -Verbose

Example 4: How to change the html signature for current user who established the connection to Office 365.
To change the html signature for current user who established the connection to Office 365, please run this command.
Set-OSCEXOEmailSignature -HtmlSignature (Get-Content C:\Scripts\051\htmlsignature.htm | Out-String) -Verbose

Note You may need a 3rd party tool or online email signature generators to make an HTML signature. After the signature is generated, please save it as an
.htm file. 

Example 5: How to clear the text signature and the html signature for current user who established the connection to Office 365.
To clear the text signature and the html signature for current user who established the connection to Office 365, please run this command.
Set-OSCEXOEmailSignature -TextSignature $null -HtmlSignature $null -Verbose
 

Additional Resources

Technical Resources:
Windows PowerShell Advanced Function
Working with user configuration objects by using the EWS Managed API

Forum Threads:
http://community.office365.com/en-us/forums/148/p/22837/111779.aspx
http://community.office365.com/en-us/forums/161/p/63217/240031.aspx 
http://community.office365.com/en-us/forums/160/p/71720/267727.aspx 
http://community.office365.com/en-us/forums/175/p/72501/271404.aspx