Script Center > Repository >
Office > Outlook signature based on user information from Active Directory

Outlook signature based on user information from Active Directory

 
 
 
 
 
(5)
Office
11/21/2010
E-mail Twitter del.icio.us Digg Facebook
Add To Favorites
Description
Q and A (4)
Verified on the following platforms
Windows Server 2008 R2 Yes
Windows Server 2008 Yes
Windows Server 2003 Yes
Windows 7 Yes
Windows Vista Yes
Windows XP Yes
Windows 2000 No
This script is tested on these platforms by the author. It is likely to work on other platforms as well. If you try it and find that it works on another platform, please add a note to the script discussion to let others know.
Online Peer Support For online peer support, join The Official Scripting Guys Forum! To provide feedback or report bugs in sample scripts, please start a new discussion on the Discussions tab for this script.
Disclaimer The sample scripts are not supported under any Microsoft standard support program or service. The sample scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.
Sign in to Ask a Question


  • Great Script, worked as promised, except......
    1 Posts | Last Post Mon 7:17 PM
    • the script worked great once I did a find and replace of all of the single and double quotes throughout it. there are ' and " quotes paired with the 6 and 9 shaped curly quotes all though the script. 
      
      Once that was done, I added things like mobile, fax (facsimileTelephoneNumber), street address, etc to the script and my signatures, worked very well except that when the script parses out the docx into an HTML, anything that is a hyperlink is converted to Times New Roman, which is no good for my signatures.
  • Error running powershell command
    1 Posts | Last Post December 12, 2011
    • hi, i recieved the following error when i try to run the command on powershell.
      
      PS C:\Users\Administrator> {Set-ItemProperty $CompanyRegPath'\Outlook Signature Settings' -name ForcedSignatureNew -Value $ForceSignatureNew}
      Set-ItemProperty $CompanyRegPath'\Outlook Signature Settings' -name ForcedSignatureNew -Value $ForceSignatureNew
      PS C:\Users\Administrator>
      PS C:\Users\Administrator> if ($ForcedSignatureReplyForward -eq $ForceSignatureReplyForward){}
      PS C:\Users\Administrator> else
      The term 'else' 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:5
      + else <<<<
          + CategoryInfo          : ObjectNotFound: (else:String) [], CommandNotFoundException
          + FullyQualifiedErrorId : CommandNotFoundException
      
      
      
      
  • Problems with $MSWord.Documents.Open($fullPath)
    1 Posts | Last Post November 25, 2011
    • Hi Jan
      
      I've changed and implemented the script for test, an production on some users, so the signature file is updated every time the users is logged on.
      But i've had many issues in my helpdesk about different errors when users is starting outlook right after logon.
      
      I've tried executing the following lines on my Windows 7 Client.
      $MSWord = New-Object -com word.application
      $fullPath = $LocalSignaturePath+"\"+$CompanyName+".docx"
      $MSWord.Documents.Open($fullPath)
      
      When i execute the last line to open the .docx document i've noticed it starts outlook.exe ....?
      I'm guessing its something about the word.application COM Object but i dont get it?
      
      Does anyone else have similar problems?
      
      Regards Simon
  • Correcc
    14 Posts | Last Post June 09, 2011
    • Hi,
      This is a wonderful script, but I report an error that I was shown in the following line:
      
      #Stamp registry-values for Outlook Signature Settings if they doesn`t match the initial script variables. Note that these will apply after the second script run when changes are made in the 
      
      "Custom variables"-section.
      if ($ForcedSignatureNew -eq $ForceSignatureNew){}
      
      
      I wonder if this correct or should be as follows:
      
      #Stamp registry-values for Outlook Signature Settings if they doesn`t match the initial script variables. Note that these will apply after the second script run when changes are made in the "Custom variables"-section.
      
      if ($ForcedSignatureNew -eq $ForceSignatureNew){}
      
      
      Tks.
    • Same for:
      
      #Insert variables from Active Directory to txt signature-file
      (Get-Content $LocalSignaturePath'\'$CompanyName'.txt') | Foreach-Object {$_ -replace "DisplayName", $ADDisplayName -replace "Title", $ADTitle -replace "TelePhoneNumber", $ADTelePhoneNumber 
      
      -replace "EmailAddress", $ADEmailAddress} | Set-Content $LocalSignaturePath'\'$CompanyName'.txt'
      
      Should be:
      
      #Insert variables from Active Directory to txt signature-file
      (Get-Content $LocalSignaturePath'\'$CompanyName'.txt') | Foreach-Object {$_ -replace "DisplayName", $ADDisplayName -replace "Title", $ADTitle -replace "TelePhoneNumber", $ADTelePhoneNumber -replace "EmailAddress", $ADEmailAddress} | Set-Content $LocalSignaturePath'\'$CompanyName'.txt'
      
      --
      I have 2 problem now:
      
      - The logo used in the template wont appear (empty square)
      - Even enforced, the sign are not applied by default
      
      Outlook 2003 on 2008 R2 RDS
      
      
    • The script has been improved by Darren Kattan, and are now re-published.
      For information about the improvements, see the following blog-post:
      http://www.immense.net/deploying-unified-email-signature-template-outlook
      
      Thanks Darren!
    • A snappy script indeed! However I am struggling how to load the correct office assembly that the script is looking for. I am running Office 2007 (x86) on a Win7 x64 platform.
      
      The errors that I recieve relate to the $saveFormat routines. 
      
      --------------------------------------------------------------------------------
      Unable to find type [Microsoft.Office.Interop.Word.WdSaveFormat]: make sure that the assembly containing this type is loaded.
      At C:\temp\EmailSignature2011\Set-OutlookSignaturev2.ps1:173 char:73
      + $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat] <<<< , “wdFormatHTML”);
          + CategoryInfo          : InvalidOperation: (Microsoft.Offic...rd.WdSaveFormat:String) [], RuntimeException
          + FullyQualifiedErrorId : TypeNotFound
       
      [ref] cannot be applied to a variable that does not exist.
      At C:\temp\EmailSignature2011\Set-OutlookSignaturev2.ps1:180 char:59
      + $MSWord.ActiveDocument.saveas([ref]$path, [ref]$saveFormat <<<< )
          + CategoryInfo          : InvalidOperation: (saveFormat:Token) [], RuntimeException
          + FullyQualifiedErrorId : NonExistingVariableReference
      ------------------------------------------------------------------------------------
      
      Any hints appreciated!
      
      
    • You could try to download and install the Primary Interop Assemblies for Office 2007 to see if that resolves the issue.
    • Doh!
      
      Worked out what my issue was...
      
      Even though I had all the Pre-Reqs installed for office etc (note x86 Office, x64 Win7 OS), the script was unable to find the interop libraries because I was running/testing the script from the native 64-bit powershell editor. The same errors occured when testing my script via a BAT file from the native cmd.exe
      
      As soon as I opened the x86 powershell_ise.exe from "C:\Windows\SysWOW64\WindowsPowerShell\v1.0" and ran the script from there it worked. Similarly, opening x86 CMD.exe from "C:\Windows\SysWOW64\" and running my batch file worked as well. Obviously having a x86 installion of office caused the issue.
      
      Since im going to deploy this script via SCCM, this wont be a problem for me as SCCM is a 32bit application, so will trigger the 32bit powershell exe.
      
      I hope someone thats having a similar issue to me stumbles across my post and finds the answer alot faster than I did
      
      Thanks again for an awesome script guys!
      
      - Scott.
    • I was wondering if there was a way to add the fax lines to the script.  we have some people with their own personal faxes?
    • Magnus: You can use $ADUser.facsimileTelephoneNumber if the fax-number is defined in Active Directory.
    • how can i turn off the check for last updated so it will run the full script each time its run?
    • You can remove the following lines to disable the version check:
      109
      110
      111
      167
    • excellent thanks.
      the other issue i'm getting is running the script from a normal user account. i'm using the vbscript to call the powershell script file but i get the error *.ps1 cannot be loaded because the execution of scripts is disabled on this system. under my admin account the executionpolicy is set to unrestricted but checking user my normal user account it says restricted. if i put this script in a gpo to run at login it wont run because of this. is there a fix for this? even if i can set for all users the executionpolicy to unrestricted would do the trick but even if i try that from an elevated powershell it complains that i don't have access to the reg key. HKLM\software\microsoft\powershell\1\shellids\microsoft.powershell.
      any help would be appreciated.
      regards 
    • You could either configure the exectuion policy via GPO (User Configuration) or alternatively launch powershell.exe with the parameter -executionpolicy bypass
    • if anyone wants to change it to check when the users account was updated last instead of when the signature template file was last modified.
      add in "$ADMofidy = $ADUser.whenChanged" with the rest of your ad variables.
      change "$SigVersion = (gci $RemoteSignaturePathFull).LastWriteTime" to be "$SigVersion = $ADMofidy"
      leave everything else and your script will check when the user account was last updated.
      
    • i was wondering if there was an quick and easy way to remove signatures? i'm running multiple sigs and i can get it to create another sig but its not setting it as default. if setting at default works it wouldn't be too much of a problem but it would still be nice to remove the sig to keep it clean and not have too many options there for the user.
      i did just have a brainwave i could have the same doc name so the new sig overwrites it.