Search the Community
Showing results for tags 'signature'.
-
Hello all, GitHub: https://github.com/captainqwerty/AutomatedOutlookSignature The above GitHub link is a modified version of a script I wrote to automate the creation of users Outlook signatures at work using details from their Active Directory account and as these details are checked at each logon it is dynamic towards changes such as job title. I have made the script a little more complex than the version we use in our environment. I have more checks for values in active directory in this version. It checks for each address element (PoBox, Street, zip code etc.), mobile, telephone, home phone (which we use for direct dial numbers), website and email, if any of these are blank in active directory the script will simply not add them to the HTML signature output so it is pretty flexible for different environments. Rather than heavily comment the script I have decided to cover it in detail in the readme, which I am in the process of writing so this will update over the next few days as I keep adding details to it but feel free to jump in and take a look and start using it 😊 If you have any questions and/or would like help altering it more for your own environment please feel free to ask in here / PM me. I have wrote the basics of the ReadMe on GitHub however I will be covering the script in more detail on there over the next few days. Here is an example of a generated email signature: Currently only tested on Outlook 2016 and Outlook 2019/O365 as that is what is in our environment, please feel free to modify the registry keys in the script to get it working on older versions of Outlook and I will happily amend the script with checks to work with more version 😊 I recommend setting the script in Group Policy as a PowerShell Logon Script. The main caveat is the users needs to have opened Outlook at least once before the script will work. So usually it goes, user logs in, opens Outlook, logs off and back on again and from then on, the signature will be displayed in all new emails and replies and if active directory details are changed such as job title, name (for example getting married) or work address etc. Once changed in AD they will update next logon. To modify this script, you only need basic PowerShell and HTML knowledge although I am more than happy to help you get the HTML to layout a signature how you desire for your own use, so please feel free to ask in thread and PM me. For those of you that are comfortable with GitHub please feel free to raise issues if you see any or suggest improvements. The reason I decided to use a script rather than Mail-Flow rules in Exchange is the undesired affects that occurred when using Mail-Flow rules: our users didn’t like the fact they couldn’t see their signature while writing emails; it was near impossible to get the signature to be applied to reply emails without just being pinned to the bottom of the thread and; it would repeat the signature at the bottom of the email over and over again and if you used a rule to detect it and not put it on again you only got the one signature at the very bottom of the message thread and not in replies. I personally found that there was not a great deal of information out there on how to control users Outlook signatures and products out there can be pricey especially for smaller businesses so I after I got this working I figured I would to share it you you guys and gals! I hope someone finds it useful Thanks everyone, QwertyMash
- 135 replies
-
- 13
-
-
- group policy
- outlook
-
(and 2 more)
Tagged with:
-
I use this script modiefied by thescareface to set Outlook signature for all our users, but I want the Reply/forward signature to be something else then the standard signature.. In reply/forward I want the signature to only have: Best Reagards FullName LastName Title Company name While all new mails should have: Best Regards FullName LastName Title Company address P.o.box etc etc How can I modify the script to handle this feature? ###########################################################################" # # Our script # ###########################################################################" #Custom variables $CompanyName = 'ourcompany' $DomainName = 'our.domain.local' $SigSource = "\\our.domain.local\sig_files\$CompanyName" $ForceSignatureNew = '1' #When the signature are forced the signature are enforced as default signature for new messages the next time the script runs. 0 = no force, 1 = force $ForceSignatureReplyForward = '0' #When the signature are forced the signature are enforced as default signature for reply/forward messages the next time the script runs. 0 = no force, 1 = force #Environment variables $AppData=(Get-Item env:appdata).value $SigPath = '\Microsoft\Signatures' $LocalSignaturePath = $AppData+$SigPath $RemoteSignaturePathFull = $SigSource+'\'+$CompanyName+'.docx' #Get Active Directory information for current user $UserName = $env:username $Filter = "(&(objectCategory=User)(samAccountName=$UserName))" $Searcher = New-Object System.DirectoryServices.DirectorySearcher $Searcher.Filter = $Filter $ADUserPath = $Searcher.FindOne() $ADUser = $ADUserPath.GetDirectoryEntry() $ADFirstName = $ADUser.FirstName $ADLastName = $ADUser.LastName $ADTitle = $ADUser.title $ADhomephone = $ADUser.homephone $ADmobile = $ADUser.mobile #Setting registry information for the current user $CompanyRegPath = "HKCU:\Software\"+$CompanyName if (Test-Path $CompanyRegPath) {} else {New-Item -path "HKCU:\Software" -name $CompanyName} if (Test-Path $CompanyRegPath'\Outlook Signature Settings') {} else {New-Item -path $CompanyRegPath -name "Outlook Signature Settings"} $SigVersion = (gci $RemoteSignaturePathFull).LastWriteTime #When was the last time the signature was written $ForcedSignatureNew = (Get-ItemProperty $CompanyRegPath'\Outlook Signature Settings').ForcedSignatureNew $ForcedSignatureReplyForward = (Get-ItemProperty $CompanyRegPath'\Outlook Signature Settings').ForcedSignatureReplyForward $SignatureVersion = (Get-ItemProperty $CompanyRegPath'\Outlook Signature Settings').SignatureVersion Set-ItemProperty $CompanyRegPath'\Outlook Signature Settings' -name SignatureSourceFiles -Value $SigSource $SignatureSourceFiles = (Get-ItemProperty $CompanyRegPath'\Outlook Signature Settings').SignatureSourceFiles #Forcing signature for new messages if enabled if ($ForcedSignatureNew -eq '1') { #Set company signature as default for New messages $MSWord = New-Object -com word.application $EmailOptions = $MSWord.EmailOptions $EmailSignature = $EmailOptions.EmailSignature $EmailSignatureEntries = $EmailSignature.EmailSignatureEntries $EmailSignature.NewMessageSignature=$CompanyName $MSWord.Quit() } #Forcing signature for reply/forward messages if enabled if ($ForcedSignatureReplyForward -eq '1') { #Set company signature as default for Reply/Forward messages $MSWord = New-Object -com word.application $EmailOptions = $MSWord.EmailOptions $EmailSignature = $EmailOptions.EmailSignature $EmailSignatureEntries = $EmailSignature.EmailSignatureEntries $EmailSignature.ReplyMessageSignature=$CompanyName $MSWord.Quit() } #Copying signature sourcefiles and creating signature if signature-version are different from local version if ($SignatureVersion -eq $SigVersion){} else { #Copy signature templates from domain to local Signature-folder Copy-Item "$SignatureSourceFiles\*" $LocalSignaturePath -Recurse -Force $ReplaceAll = 2 $FindContinue = 1 $MatchCase = $True $MatchWholeWord = $Talse $MatchWildcards = $False $MatchSoundsLike = $False $MatchAllWordForms = $False $Forward = $True $Wrap = $FindContinue $Format = $False #Insert variables from Active Directory to rtf signature-file $MSWord = New-Object -com word.application $fullPath = $LocalSignaturePath+'\'+$CompanyName+'.docx' $MSWord.Documents.Open($fullPath) $FindText = "FirstName" $ReplaceText = $ADFirstName.ToString() $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll ) $FindText = "LastName" $ReplaceText = $ADLastName.ToString() $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll ) $FindText = "Title" $ReplaceText = $ADTitle.ToString() $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll ) $FindText = "homephone" $ReplaceText = $ADhomephone.ToString() $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll ) $FindText = "svgmobile" $ReplaceText = $ADmobile.ToString() $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll ) $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatHTML"); $path = $LocalSignaturePath+'\'+$CompanyName+".htm" $MSWord.ActiveDocument.saveas([ref]$path, [ref]$saveFormat) $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatRTF"); $path = $LocalSignaturePath+'\'+$CompanyName+".rtf" $MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$saveFormat) $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatText"); $path = $LocalSignaturePath+'\'+$CompanyName+".txt" $MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$SaveFormat) $MSWord.ActiveDocument.Close() $MSWord.Quit() } #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){} else {Set-ItemProperty $CompanyRegPath'\Outlook Signature Settings' -name ForcedSignatureNew -Value $ForceSignatureNew} if ($ForcedSignatureReplyForward -eq $ForceSignatureReplyForward){} else {Set-ItemProperty $CompanyRegPath'\Outlook Signature Settings' -name ForcedSignatureReplyForward -Value $ForceSignatureReplyForward} if ($SignatureVersion -eq $SigVersion){} else {Set-ItemProperty $CompanyRegPath'\Outlook Signature Settings' -name SignatureVersion -Value $SigVersion}
-
I have been using a script I wrote about 4 years ago to set users' signatures on login. This has worked fine until a couple of days ago when vbscript has started throwing an error: Error: Object doesn't support this property or method: 'NewMessageSignature' Code: 800A01B6 Source: Microsoft VBScript runtime error I have stripped the rather long script down into the raw basics of generating a signature of a single word and adding it (no AD queries etc to interfere or cause problems). The signature is added and I can see it if I go into outlook under the signatures preferences, but the signature is not added for new or reply messages. The block of code it falls over on is: objSignatureEntries.Add strSignatureName, objSelection objSignatureEntries.NewMessageSignature = strSignatureName objSignatureEntries.ReplyMessageSignature = strSignatureName I have not deployed any new WSUS updates around the time of this problem appearing, and the script has been unchanged for at least a year. This is happening on both Outlook 2007 and Outlook 2010. Has anyone got any ideas or suggestions, or has anyone else started experiencing this problem? Thanks, James Option Explicit Dim objNet : Set objNet = CreateObject("WScript.NetWork") Dim objFSO : set objFSO = createobject("Scripting.FileSystemObject") Dim objShell : Set objShell = WScript.CreateObject("WSCript.shell") Dim objWord : Set objWord = CreateObject("Word.Application") Dim objDoc : Set objDoc = objWord.Documents.Add() Dim objSelection : Set objSelection = objWord.Selection Dim objEmailOptions : Set objEmailOptions = objWord.EmailOptions Dim objSignatureObjects : Set objSignatureObjects = objWord.EmailOptions.EmailSignature Dim objSignatureEntries : Set objSignatureEntries = objSignatureObjects.EmailSignatureEntries objSelection.TypeParagraph objSelection.TypeText "test" Set objSelection = objDoc.Range() Dim strSignatureName : strSignatureName = "test" objSignatureEntries.Add strSignatureName, objSelection objSignatureEntries.NewMessageSignature = strSignatureName objSignatureEntries.ReplyMessageSignature = strSignatureName objDoc.Saved = TRUE objDoc.Close 0 objWord.Quit
-
Morning all Found this script from TechNet: https://gallery.technet.microsoft.com/office/6f7eee4b-1f42-499e-ae59-1aceb26100de#content It's very well featured and does what I want it to do. However, when it generates the signature for a user who has not launched Outlook before, Outlook launches. I can't for the life of me figure out why Outlook wants to launch because I can't see anything in the script that should be calling it? Hoping one of you guys may be able to help me out with this one. I have made some changes to the original script to try and get it to work without launching Outlook, so I have pasted the version that I am running at the moment, below. Thanks Steve <# .SYNOPSIS Script to set Outlook signature for Outlook 2010 or Outlook 2013 .DESCRIPTION Script to set Outlook signature as either available or forced. Tested on Office 2010 and Office 2013. Provided AS IS with no warranty. This script is a modified version of Jan Egil's script: http://gallery.technet.microsoft.com/office/6f7eee4b-1f42-499e-ae59-1aceb26100de Some of the modifications made: - Removed signature version stamp in registry - Ability to set the signature version - When setting the signature as available, the COM object is used and when forced, a registry change is applied - Removed a lot of things removed that did not fulfill my needs - A lot of other things that I don't remember Author: Daniel Classon Version: 1.0 History: 1.0 2014-09-24 - First version released Step-by-Step 1. Create a *.docx file 2. Edit the file so it looks the way you want the signature to look and edit text to correspond with the AD properties further down in the script. For example the test "Title" corresponds to the AD property "title". 3. Edit the section #Custom variables 4. Run the script 5. Done! #> #Custom variables $SignatureName = 'Signature' #Insert desired name of signature. This will name will appear in Outlook. $SigSource = "\\path omitted" #Provide full path to the *.docx signature file $SignatureVersion = "1.1" #Change this if you have updated the signature. If you do not change it, the script will quit after checking if signature is up to date. $ForceSignature = '1' #If set to '0', the signature will be editable in Outlook and if set to '1' will be non-editable and forced. $DefaultAddress = 'omitted' $DefaultCity = 'omitted' $DefaultTelephone = 'omitted' #Environment variables $AppData=(Get-Item env:appdata).value $SigPath = '\Microsoft\Signatures' $LocalSignaturePath = $AppData+$SigPath $RemoteSignaturePathFull = $SigSource #Copy version file If (!(Test-Path -Path $LocalSignaturePath\$SignatureVersion)) { New-Item -Path $LocalSignaturePath\$SignatureVersion -Type Directory } Elseif (Test-Path -Path $LocalSignaturePath\$SignatureVersion) { Write-Output "Latest signature already exists" break } #Check signature path (needs to be created if a signature has never been created for the profile if (!(Test-Path -path $LocalSignaturePath)) { New-Item $LocalSignaturePath -Type Directory } #Get Active Directory information for current user $UserName = $env:username $Filter = "(&(objectCategory=User)(samAccountName=$UserName))" $Searcher = New-Object System.DirectoryServices.DirectorySearcher $Searcher.Filter = $Filter $ADUserPath = $Searcher.FindOne() $ADUser = $ADUserPath.GetDirectoryEntry() $ADDisplayName = $ADUser.DisplayName $ADEmailAddress = $ADUser.mail $ADTitle = $ADUser.title $ADDescription = $ADUser.description $ADTelePhoneNumber = $ADUser.TelephoneNumber $ADFax = $ADUser.facsimileTelephoneNumber $ADMobile = $ADUser.mobile $ADStreetAddress = $ADUser.streetaddress $ADCity = $ADUser.l $ADPOBox = $ADUser.postofficebox #$ADCustomAttribute1 = $ADUser.extensionAttribute1 $ADModify = $ADUser.whenChanged #Copy signature templates from domain to local Signature-folder Write-Output "Copying Signatures" Copy-Item "$Sigsource" $LocalSignaturePath -Recurse -Force $ReplaceAll = 2 $FindContinue = 1 $MatchCase = $False $MatchWholeWord = $True $MatchWildcards = $False $MatchSoundsLike = $False $MatchAllWordForms = $False $Forward = $True $Wrap = $FindContinue $Format = $False #Insert variables from Active Directory to rtf signature-file $MSWord = New-Object -ComObject word.application $fullPath = $LocalSignaturePath+'\'+$SignatureName+'.docx' $MSWord.Documents.Open($fullPath) #User Name $ Designation $FindText = "DisplayName" #$Designation = $ADCustomAttribute1.ToString() #designations in Exchange custom attribute 1 If ($Designation -ne '') { $Name = $ADDisplayName.ToString() $ReplaceText = $Name #+', '+$Designation } Else { $ReplaceText = $ADDisplayName.ToString() } $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll ) $LogInfo += $NL+'Username: '+$ReplaceText #Title $FindText = "Title" $ReplaceText = $ADTitle.ToString() $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll ) $LogInfo += $NL+'Title: '+$ReplaceText #Mail $FindText = "mail" $ReplaceText = $ADEmailAddress.ToString() $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll ) $LogInfo += $NL+$ReplaceText #Description If ($ADDescription -ne '') { $FindText = "Description" $ReplaceText = $ADDescription.ToString() } Else { $FindText = " | Description " $ReplaceText = "".ToString() } $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll ) $LogInfo += $NL+'Description: '+$ReplaceText #Street Address If ($ADStreetAddress -ne '') { $FindText = "StreetAddress" $ReplaceText = $ADStreetAddress.ToString() } Else { $FindText = "StreetAddress" $ReplaceText = $DefaultAddress } $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll ) $LogInfo += $NL+'Street Address: '+$ReplaceText #City If ($ADCity -ne '') { $FindText = "City" $ReplaceText = $ADCity.ToString() } Else { $FindText = "City" $ReplaceText = $DefaultCity } $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll ) $LogInfo += $NL+'City: '+$ReplaceText #Telephone If ($ADTelephoneNumber -ne "") { $FindText = "TelephoneNumber" $ReplaceText = $ADTelephoneNumber.ToString() } Else { $FindText = "TelephoneNumber" $ReplaceText = $DefaultTelephone } $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll ) $LogInfo += $NL+'Telephone: '+$ReplaceText #Mobile If ($ADMobile -ne "") { $FindText = "MobileNumber" $ReplaceText = $ADMobile.ToString() } Else { $FindText = "| Mob MobileNumber " $ReplaceText = "".ToString() } $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll ) $LogInfo += $NL+'MobileNumber: '+$ReplaceText #Save new message signature Write-Output "Saving Signatures" #Save HTML $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatHTML"); $path = $LocalSignaturePath+'\'+$SignatureName+".htm" $MSWord.ActiveDocument.saveas([ref]$path, [ref]$saveFormat) #Save RTF $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatRTF"); $path = $LocalSignaturePath+'\'+$SignatureName+".rtf" $MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$saveFormat) #Save TXT $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatText"); $path = $LocalSignaturePath+'\'+$SignatureName+".txt" $MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$SaveFormat) $MSWord.ActiveDocument.Close() $MSWord.Quit() #Office 2010 If (Test-Path HKCU:'\Software\Microsoft\Office\14.0') { Write-Output "Setting signature for Office 2010" If (Get-ItemProperty -Name 'ReplySignature' -Path HKCU:'\Software\Microsoft\Office\14.0\Common\MailSettings' -ErrorAction SilentlyContinue) { Write-Output "Signature already exists" } Else { New-ItemProperty HKCU:'\Software\Microsoft\Office\14.0\Common\MailSettings' -Name 'ReplySignature' -Value $SignatureName -PropertyType 'String' -Force New-ItemProperty HKCU:'\Software\Microsoft\Office\14.0\Common\MailSettings' -Name 'NewSignature' -Value $SignatureName -PropertyType 'String' -Force } } If ((Test-Path HKCU:'\Software\Microsoft\Office\14.0') -eq $False) { Write-Output "Office 2010 is not installed" } #Office 2013 If (Test-Path HKCU:'\Software\Microsoft\Office\15.0') { Write-Output "Setting signature for Office 2013" If ($ForceSignature -eq '0') { Write-Output "Setting signature for Office 2013 as available" #$Outlook = "Outlook" #if ($Outlook -ne $null) #{ #Stop-Process -Name $Outlook -Force #} $MSWord = New-Object -comobject word.application $EmailOptions = $MSWord.EmailOptions $EmailSignature = $EmailOptions.EmailSignature $EmailSignatureEntries = $EmailSignature.EmailSignatureEntries $EmailSignature.NewMessageSignature="$SignatureName" $EmailSignature.ReplyMessageSignature="$SignatureName" #Stop-Process -Name $Outlook } If ($ForceSignature -eq '1') { Write-Output "Setting signature for Office 2013 as forced" If (Get-ItemProperty -Name 'NewSignature' -Path HKCU:'\Software\Microsoft\Office\15.0\Common\MailSettings' -ErrorAction SilentlyContinue) { } Else { New-ItemProperty HKCU:'\Software\Microsoft\Office\15.0\Common\MailSettings' -Name 'NewSignature' -Value $SignatureName -PropertyType 'String' -Force } If (Get-ItemProperty -Name 'ReplySignature' -Path HKCU:'\Software\Microsoft\Office\15.0\Common\MailSettings' -ErrorAction SilentlyContinue) { } Else { New-ItemProperty HKCU:'\Software\Microsoft\Office\15.0\Common\MailSettings' -Name 'ReplySignature' -Value $SignatureName -PropertyType 'String' -Force } } } If ((Test-Path HKCU:'\Software\Microsoft\Office\15.0') -eq $False) { Write-Output "Office 2013 is not installed" }
-
- office365
- powershell
-
(and 1 more)
Tagged with:
-
Hi! I'm trying to roll out a uniformed signature for the company and while it works perfectly in Outlook itself using the method of copying and pasting the files of the signature, doing it through OWA gave me a bit of issue because the coding was way too long. I cleaned up the coding a bit and it fit within the character limit for OWA signature and all testing worked fine.... however when I check the signature on OWA, it looks exactly how I intended but when I check the same email in my Outlook, the formatting is off. I don't know how to solve this.... does anyone have any idea on how to make it work? Thanks!
-
- compatilibity mode
- emails
-
(and 3 more)
Tagged with:
