Introduction

The Powershell-based Outlook signature solution provided in this blog post was created because I was unable to find any other solutions that met my expectations.

The only script that came close to my needs was the one provided by Jan Egil: http://gallery.technet.microsoft.com/office/6f7eee4b-1f42-499e-ae59-1aceb26100de, but it returned quite a few errors, was missing some functions I needed, but also had other functions, that was not needed in my case.

Note that the script was last updated in 2014, and I currently have no plans for updating it (as of 2019-09-16). It has not been tested on Outlook versions following Office 2013.

The Outlook signature script solution

This script will gather information from Active Directory and automatically populate the fields in the signature.

Here is my script, and thanks again to Jan Egil for providing the original functionality 🙂

Download: TechNet Gallery

21 COMMENTS

  1. Excellent article Daniel! For those of us still plowing through the learning curve – would you mind expanding on the “Step by Step” section please? Particularly step #2 and #4. I have *.docx file formatted but not sure if it needs to be bookmarks or keywords or what. An example would be great. Step #4, does this get run via Logon spcript in Active Directory or GPO or somewhere else? Thank you very much in advance.

  2. Thanks Thomas! I will put some more information in the post 🙂 You can deploy it via login script or GPO, but I would recommend to create a package in SCCM and deploy it to the clients. Are you using SCCM or any other deployment solution?

    What you need to do in step 2 is to add text that matches the ones in the script and it will replace them with the property found in Active Directory.

    For example, if you want to use DisplayName (e.g Sam Smith) from AD, the script will look in the document for “DisplayName” and change it to the property stored in the variable earlier:

    Here the script gets the DisplayName from AD:

    $ADDisplayName = $ADUser.DisplayName

    Here it looks for text in the document:

    #User Name $ Designation
    $FindText = “DisplayName”

    And here it replaces the text with the DisplayName property stored in AD

    $ReplaceText = $ADDisplayName.ToString()

    The script gets all the information from the logged on user.

    If you have any further questions, feel free to ask them 🙂

  3. This is very useful, Thank you very much. But I can’t get it work by GPO to run at login. I suspect the script is running in the system context by using the GPO. SCCM would be no option because I am using Xenapp. Do you have any idea to run that script on every client at every login?
    Thanks in advance
    Christoph

  4. Hi,

    I’ve tried this script but I get errors:

    You cannot call a method on a null-valued expression.
    At C:\Users\manny.landsman\Sig.ps1:125 char:43
    + $ReplaceText = $ADDescription.ToString <<<< ()
    + CategoryInfo : InvalidOperation: (ToString:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    It does this for every line during the AD query,

    Help please!

  5. Good Day,

    We are having an issue with the script and Word. The issue is intermittent. Sometimes Everything works great and files are created. But, half of the time we get error “Access Validation” WinWord.exe – and the save file failed.

    Please see below:

    Log Name: Application

    Source: Application Error

    Date: 3/20/2015 3:19:32 PM

    Event ID: 1000

    Task Category: (100)

    Level: Error

    Keywords: Classic

    User: N/A

    Description:

    Faulting application name: WINWORD.EXE, version: 14.0.7140.5000, time stamp: 0x5462a654

    Faulting module name: MSVCR90.dll, version: 9.0.30729.4940, time stamp: 0x4ca2ef57

    Exception code: 0xc0000417

    Fault offset: 0x000320f0

    Faulting process id: 0x1aa0

    Faulting application start time: 0x01d06342c6d633f5

    Faulting application path: C:\Program Files (x86)\Microsoft Office\Office14\WINWORD.EXE

    Faulting module path: C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4940_none_50916076bcb9a742\MSVCR90.dll

    Report Id: 08df490a-cf36-11e4-aa4d-00155d01174a

    Event Xml:

    1000

    2

    100

    0x80000000000000

    3776

    Application

    WINWORD.EXE

    14.0.7140.5000

    5462a654

    MSVCR90.dll

    9.0.30729.4940

    4ca2ef57

    c0000417

    000320f0

    1aa0

    01d06342c6d633f5

    C:\Program Files (x86)\Microsoft Office\Office14\WINWORD.EXE

    C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4940_none_50916076bcb9a742\MSVCR90.dll

    08df490a-cf36-11e4-aa4d-00155d01174a

    Any Idea?

    We have tested on many Workstations. Different Profiles and User Data.

    Thanks TM

  6. Hi Daniel

    I found my way to your script via Jan Egil.
    I struggled a bit to get it working. I found out that I needed to remove the [ref] in the Write-Output “Saving Signatures” section.
    I was so happy to get it to work, until I tried it on another pc, where it didnt work, I needed to put the [ref] back in to the script.
    I did some investegating and found out that there is a difference between win 8 and win8.1 powershell.
    Do you or does anyone reading this know how to make it work on both windows ??
    As I said I suspect it is the differnce of powershell versions (win 8 is running PS 3.0 and win 8.1 is running PS 4.0)

  7. Hey Daniel! This script is awesome! We actually have a VBS script that does exactly this, but i’ve seen it hang if/when you launch Outlook while the script is still running…I haven’t tested this out just yet but i was wondering if the runtime on the powershell 1 is better or if you’ve seen any conflicts in outlook when running this?

    • Hey! The script will close Outlook if it’s running, because, as you mentioned, there might be conflicts when having Outlook opened while the script is running. I haven’t had any issues with this 🙂 I will release a new version of this script in the next couple of days, so stay tuned.

  8. HI The script is great and worked well for me, I was wondering if you can help with a slight customization. I want the signature to be set as default for new messages only but i want the option to allow staff to edit and put their mobile numbers in. At the moment if i force it it greys out the options and does not allow modification. On the other hand if I don’t force it it does not set as their default if they already have their own signature.

  9. Hi,

    This script is very well. I only have a question. How would it be possible to completely erase the line who contain nothing ?

    In place of replace the text, completely delete the line ?

    Best regards

    ps : sorry for my english

  10. Just wanted to say thank you for taking the time to work this out. I tweaked it heavily to suit my signature needs, and ended up using the script to create four distinct signatures per user. Thank you, thank you, thank you.

  11. Hi Daniel

    Wow! I didn’t know you responded on post 🙂 (I thought I would have gotten an email about it)
    But great that you are working on an update.
    In the meantime I have looked some more into it and I think the problem is the Outlook 2013 version and not the powershell. I use Office 365 and have installed Outlook on my pc, which is an 365 version of Outlook 2013.
    I have tried to see if I could get the version number, so I could do an compare on 2013 versions.
    This has not been possible yet. But maybe it will help you or anybody else to find an solution on the [ref] issue.
    I wonder why nobody else has come across this issue ??
    looking forward to see the update

  12. Hi Daniel,

    do you know how I can set more then one default signature?

    My Problem is I have two mail adresses in one outlook profile.
    Mail adress A needs another default signature as mail adress B.

    I have no idea how I can set two different default signatures.

  13. Hi Xpsit. you will not get it to work with multiple profiles. While the powershell script can work to some extend, if you don’t use images, there is no point in spending so much time trying to get it work, when there are so many cheap solutions out there. Check out outlooksignatures.com for example, a simple version that will handle multiple profiles, visual design and the price is marginal

  14. The mail field is not updating in the signature, all fields are completed in AD. I’ve tried other iterations of mail in the template (mail, emailAddress, email, etc etc). Any idea why that field wouldn’t fill even though it is completed in AD? All other AD fields fill in.

  15. After looking more closely I didn’t find a mail item in the script and it wasn’t included in the template. I added the mail item and pointed it to find the field in AD. Thanks. But now another question… If you use the ForceSignature = 1 and then decide not to use it, how do you update the Outlook settings? I changed the ForceSignature back to 0 and changed the version number and ran the script again but the Signature options in Outlook are still locked. I looked for the registry items listed in the script to directly edit those but now they don’t exist. Should I just reinstall Outlook or is there an easier way?

LEAVE A REPLY

Please enter your comment!
Please enter your name here