Set Outlook Web App signature with image using PowerShell

Applies to Exchange 2016, Exchange 2013, Exchange 2010 and Exchange Online (Office 365).

In corporate environments central management of email signatures is a must – you don’t want users messing up the company’s image by sending out emails stamped with notes in Comic Sans, lacking crucial contact info, etc.

So it’s a good thing that Microsoft Exchange platforms offer several means of controlling the email footer situation in your network. The most popular one is the Apply disclaimers feature available via Exchange transport rules, which I’ve talked about extensively on this blog (see respective guides for Exchange Online, 2016, 2013, 2010 and 2007).

How to set Outlook Web App signature with image using PowerShell

Another way of deploying email signatures from one place across an Exchange organization, is using the Set-MailboxMessageConfiguration PowerShell cmdlet with the -SignatureHTML parameter.

This method allows you to populate the Email signature box in end-users’ Outlook Web App / Outlook on the Web clients with any type of HTML content: text, tables, images, links, etc.

Required permissions

To be able to centrally set users’ OWA email signatures you need to be assigned Server Management permissions. This can be done either via Exchange admin center or using PowerShell (learn more…).

Preparation

  • First of all, you need to prepare the HTML code you will send out to OWA clients.

    Make sure to upload the images that you will use in the signature to a public web server, so that you can insert them into the code using <IMG SRC> tags.

    NOTE: There is no direct way of downloading users’ Active Directory data into the template, so the email signature design you will use, should only contain general company information, images and links.  You can find examples of business email signature designs in our Signature Template library.
    To add users’ personal data into the template, you could use our free email signature generator, generate the HTML code with placeholders and use Get-Mailbox to get users’ data and finally, substitute placeholders with the data. However, this procedure requires some PowerShell and scripting skills.

    Pasting raw HTML into PowerShell is not advisable (if at all possible?), so once you have the HTML code, save it to a TXT file on your disk. I will explain how to feed it to PowerShell in a moment.

  • Another important thing is that you have PowerShell access to Exchange or Office 365. Unless you are working on a machine that has Exchange Management Shell installed on it, refer to the below article for details on what to do:

    How to start remote PowerShell session to Exchange or Office 365

Importing the HTML code into PowerShell

Before you can deploy the email signature to OWA clients, you have to import its code into a variable in PowerShell.

You do this by running the below command:

$<Name of variable> = Get-Content <Path of prepared TXT file>

Example:

$SignatureSocial = Get-Content C:\SignatureSocial.txt

Deploying the email signature to Outlook Web App clients

To deploy the imported email signature to users’ Outlook Web App clients and set it to automatically add to emails, you have to run the below command:

Get-Mailbox -RecipientTypeDetails UserMailbox | Set-MailboxMessageConfiguration -SignatureHTML $<Name of variable> -AutoAddSignature:$true

You can check if the setting has been applied correctly, by going to Outlook Web App Options, Mail, Layout, Email signature.

This is what it looked like when I deployed my example signature with images:

Outlook Web App, Options, Email Signature

NOTE: If you ever want to get rid of the email signature in users’ OWA clients, follow this article.

Related Software

CodeTwo Exchange Rules: Central management of email signatures for on-premises Exchange

CodeTwo Email Signatures for Office 365: Central management of email signatures in Office 365

CodeTwo Email Signatures for Email Clients: Design email signatures centrally and deploy to OWA, Outlook and Gmail

9 thoughts on “Set Outlook Web App signature with image using PowerShell

    1. Kamil Glaser

      Yes, you could add user details into the signature. Using one of the templates from the free email signature generator, you could create a signature with AD placeholders. Those placeholders will not work with the code provided in the article, but with some scripting and PowerShell knowledge, you should be able to get users’ details with Get-Mailbox and replace the placeholders with the right data.
      To be honest, creating a mail flow rule which adds server-side email signature to each email seems like a more reliable option. Here is a video tutorial for setting up a global email signature in Office 365.

      Reply
  1. Domingos Varela

    Hi,
    I am trying to follow the steps, but I have this powershell error
    Thanks
    Regards


    PS C:\WINDOWS\system32> Get-Mailbox -RecipientTypeDetails UserMailbox | Set-MailboxMessageConfiguration -SignatureHTML $SignatureSocial -AutoAddSignature:$true
    Get-Mailbox : The term ‘Get-Mailbox’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
    included, verify that the path is correct and try again.
    At line:1 char:1
    + Get-Mailbox -RecipientTypeDetails UserMailbox | Set-MailboxMessageCon …
    + ~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (Get-Mailbox:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    Reply
    1. Kamil Glaser

      Hi Domingos,
      there are two possible reasons for getting this PowerShell error. Either you have not connected to your Exchange environment, or you don’t have the required permissions to run the Get-Mailbox cmdlet.
      How to start remote PowerShell session to Exchange or Office 365 – the article will help you if you haven’t connected to Exchange. If it is a permission issue, you need your Exchange administrator to give you the right permissions (or run the cmdlet for you).

      Reply
      1. Domingos Varela

        Hi Kamil,

        You were correct I had not connected correctly to exchange, I was able to connect and insert the signature on all users, but I am having problems with the variables, user data is being shown as variables like;

        %% Company %%
        %% DisplayName %%
        %% Title %%
        %% Department %%
        %% Office %%
        %%Email%%

        What are the variables he accepts!
        Thanks

        Regards
        Domingos Varela

        Reply
        1. Kamil Glaser

          Those placeholders would work just fine if they were without spaces and if you used them in the mail flow method of setting up email signatures.
          If you want to set up email signatures using the method from the article above, you either have to create a general email signature with no user-specific elements, or make the script much more sophisticated, so that it gets users’ details with, for example, Get-Mailbox or Get-ADUser cmdlets and replaces the placeholders you use in the HTML code.

          Reply
  2. Domingos Varela

    I thought he used the same variables, how can I disable it while trying to create something more functional.
    Thank you so much for your support and attention.
    Regards

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *