Outlook signature generator script

Generates Outlook signatures and can embed user details from Active Directory such as an email address or phone number. Any relevant AD attribute can be embedded. Will process all templates in a defined folder and supports default new/reply settings and deleting signatures.

4 Star
751 times
Add to favorites
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question

  • Error and Doesn't set New Reply When Outlook 365 Open
    1 Posts | Last post May 04, 2019
    • Chris
      The script is almost 100% functional for me.  But I get the error below everytime I run it from PS with Outlook 365 closed.
      Write-EventLog : The source name "OutlookSignature" does not exist on computer "localhost".
      At C:\Users\user\Desktop\MySignature\OutlookSignature\OutlookSignatureScript.ps1:37 char:13
      If Outlook is open it does not set the signature for "New" emails.  It does set it for New emails if Outlook 365 is closed.
      Additional Error When Outlook 365 Open
      Specified cast is not valid.
      At C:\Users\user\Desktop\MySignature\OutlookSignature\OutlookSignatureScript.ps1:272 char:21
      + ...             $Word.EmailOptions.EmailSignature.NewMessageSignature = $ ...
  • Windows 7 - Error
    1 Posts | Last post March 29, 2019
    • Hello,the script work perfect on Windows 10 with the change done by MarkoKuky but when run on Windows 7 get error, is like try to edit the word on the shared folder (the users has only rights for read and execute)
  • Detect signature path automatically
    1 Posts | Last post February 17, 2019
    • Thanks for sharing! It is a great script and works flawlessly with suggested changes from MarkoKuky.
      It would be nice if the script could detect the installed language automatically and set the signature path accordingly.
      I have Office with Swedish language installed in my domain and for some reason some signature paths are in English and some in Swedish.
      I suppose Office 2019 signature path is in English regardless of interface language which is Swedish in my case.
      Signature path in English:
      Signature path in Swedish:
  • Cannot create *.html file
    1 Posts | Last post December 04, 2018
    • Hi Chris,
      Thanks for sharing. Do you have any idea why I get an error on line #254:
      1 template(s) found at: C:\Users\[.........]\Downloads\OutlookSignatureScript\
      Outlook profile status: Default profile found.
      Template, Action, Invalid Tags, Status 
      Long_Sig.docx, None, 0, Error: Exception setting "SaveAs": Cannot convert the "C:\Users\[.........]\AppData\Roaming\Microsoft\Signatures\Long_Sig.htm" value of type "psobject
      " to type "Object".
      Exception setting "SaveAs": Cannot convert the "C:\Users\[.........]\AppData\Roaming\Microsoft\Signatures\Long_Sig.htm" value of type "psobject" to type "Object".
      At C:\Users\[.........]\OutlookSignatureScript\OutlookSignatureScript.ps1:254 char:13
      +             $Word.ActiveDocument.SaveAs([Ref]$SavePath, [Ref][Microso ...
      +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
          + FullyQualifiedErrorId : RuntimeException
  • Exception from HRESULT: 0x80020005 Error
    4 Posts | Last post November 16, 2018
    • Hi Chris,
      Thanks for this script, I'm trying to use this but after I finish all needed setting I'm still getting this error:
      WARNING: The source was not found, but some or all event logs could not be searched.  Inaccessible logs: Security.
      Exception calling "SaveAs" with "2" argument(s): "Type mismatch. (Exception from HRESULT: 0x80020005
      At C:\Outlook_Signature.ps1:254 char:13
      +             $Word.ActiveDocument.SaveAs([Ref]$SavePath, [Ref][Microsoft.Office.I ...
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
          + FullyQualifiedErrorId : COMException
      Can you help me with this?
    • Hi Anis,
      If you paste the following into Powershell does it return true or false?
      Test-Path -Path ($env:APPDATA+'\Microsoft\Signatures')
      From the config at the top of the script:
      # Path Outlook loads signature files from, default is for English localisations.
      $OutlookSignaturePath = $env:APPDATA+'\Microsoft\Signatures'
      If the machine running the script is not using English you will need to check this path.
    • I solved it by doing this(lines 252-261):
       # save the signature template files in html/rtf/txt formats
                  [string]$SavePath = Join-Path -Path $OutlookSignaturePath -ChildPath "$TemplateName.htm"
                  $Word.ActiveDocument.SaveAs([Ref]$SavePath, 8)
                  [string]$SavePath = Join-Path -Path $OutlookSignaturePath -ChildPath "$TemplateName.rtf"
                  $Word.ActiveDocument.SaveAs([Ref]$SavePath, 6)
                  [string]$SavePath = Join-Path -Path $OutlookSignaturePath -ChildPath "$TemplateName.txt"
                  $Word.ActiveDocument.SaveAs([Ref]$SavePath, 2)
    • Hi Marko,
      Thanks for the details of what fixed it for you. What version of Office/Word are you running this with? Did you make any other changes? I can't recreate the original issue at the moment.