Jump to content
  • entries
    78
  • comments
    135
  • views
    2,236

Centrally managing Signatures in Outlook and OWA - the free way


Introduction

Right... as part of a corporate branding exercise - I have been working on sorting out the email signature front.

 

Before everyone says it - yes, I know you can do a "sort of solution" on the Exchange server. Im not going to cover that one in this post - as its more designed for Disclaimers. If you want to know more on that - Google "Exchange Transport Rule Disclaimer".

 

Why not Exchange Transport Rules

Back to this post - and why I didnt use Exchange server. Well - the one big bug/by design behavior with the Transport Rule option is that it cant work out where the body of a reply or forward is - and therefore can only tag its content to either the start or end of the entire message.

 

The Solution

Enter my solution. What I wanted to do was add a customised signature via Outlook and Web Access to all messages. Yes - I know that in theory these could be editted by the users - but I will come back to that one.

 

Lets start with Outlook. First off, lets get friendly with some scripting. This is Powershell - and you need Windows 7 (built in) or XP SP3 (with Powershell 2.0 addin free download from Microsoft Download Centre).

 

Create your Outlook Template

Now - we need to create a kind of template to use. This should be done in Word - and call it CompanyName.docx (replace Company Name with your School name). Create the look and feel you want your signature to have - and yes you can include images! Make sure you use the following keywords: DisplayName, Title, Email, TelephoneNumber, Fax etc..

 

THis is a bit of a noob thing - but you must ensure these fields are filled out for all users in Active Directory Users and Computers. This is designed to save you time - information in one location.

 

Put your file on your server under the following path \\domain\NETLOGON\sig_files\CompanyName\CompanyName.docx

 

Now - here is the script. I cant take any credit for this - other than the find - and confirming that it works like a dream. You will need to edit sections at the top - the variables for your site. It is uploaded here as a txt - save it as a .ps1 file.

SetOutlookSignature.txt

 

Source Credit: http://www.immense.net/deploying-unified-email-signature-template-outlook/

 

Group Policy Fun

Next, you need to get busy with Group Policy. Two things we need to do - one assign our script. Thats under User Configuration > Policies > Windows Settings > Scripts > Logon. Another caveat here - which I should have mentioned earlier. You NEED to be Server 2008 R2 really for this. On the Scripts dialog, you have a second tab "Powershell". Click Browse - and copy your script to this location (which will be a folder within Sysvol.....GUID....Scripts/Login. This is really important. Powershell is so damn powerful that Microsoft have built in a load of protection. By default, unsigned scripts cannot run, and ours certainly isnt! But, by putting it here - it will run safely.

 

So... Thats done. Next - to lock down Outlook to prevent users fiddling with Outlook settings. Sadly, the Office 14 ADMX files (free download from the Microsoft Download Centre) do not give you check boxes to disable features. We have to know the IDs of the controls we want to disable.

 

These are... 5608, 14014, 11323, 21553, 5611, 14823, 12305, 16182, 13991, 12245, 12680, 12863, 12681, 12864, 2087 and you put them here Microsoft Outlook 2010 > Disable Items in User Interface > Custom

 

Outlook Web Access

Onto OWA. Yes you can get to the Signatures here as well - under Options. Thankfully - you can prevent access to it via Web Access policies in the Exchange Management Console. But - again, with a little bit of Powershell on the server, we can ensure that a signature we want is set there too - for when your users send email from there.

 

$mailboxes = Get-Mailbox
$mailboxes| foreach {$file= "C:\signatures\" + ($_.alias) + ".html"; Set-MailboxMessageConfiguration -identity $_.alias -SignatureHtml "$(Get-Content -Path $file -ReadCount 0)"}

 

Source Credit: http://blog.exchangegeek.com/2010/08/manage-owa-signatures-using-powershell.html

 

Now - one problem with this - you need to have pre-created an HTML signature for each user, and as per the script as is - located it in C:\signatures; issue! So, how to fix that...

 

Well, that will be the subject of my next post - and as a teaser as to the fix, think about what the first Outlook bit is doing! If i can sort out a small prize for BETT, this will be awarded if a member can come up with what the answer is (which is already part written as my next article). Bear in mind - Ive already implemented this....

 

Questions and comments welcome :-)

Edited by TheScarfedOne

11 Comments


Recommended Comments

dimepop

Posted

Hi, have you got the code to create am html signature for each user?

Thanks

ctsmith47

Posted

Thank you for this post, lots of great info.

 

Did you ever get a chance to complete the Outlook Web Access portion on another post?

AnotherAdmin

Posted

Any updates on getting the OWA signature working? The outlook script worked like a charm, but the OWA would be very helpful!!
RabbieBurns

Posted

Any idea how I can centrally customise the signature for Outlook for Mac?
rinzwind

Posted

Just to be helpfull... profilehelper by ws does this through the group policy management console this and it's quite affordable I think.
timbo343

Posted

@TheScarfedOne is there any chance of providing the link/information to configuring OWA signatures please, most of the staff here use OWA instead of Outlook.
BrettH

Posted (edited)

Hello everyone! First, I'd just like to pass my thanks to TheScarfedOne and the creator(s) of the scripts listed here. This was a huge help in setting up Outlook and OWA signatures for my company. Since TheScarfedOne never posted his next post about creating individual OWA signature files, I thought that I'd share mine with everyone.

 

The script below is customized for my company. It takes into account whether or not a user has a Cell number, Fax Number, both, or neither and applies that to a custom signature. It is also setup to only work if the user has an email address and an enabled account. This script does not contain a logo, but at the bottom, I've shown how to add one. Please pardon my crude coding. Also, I got this script from https://4sysops.com/archives/add-a-signature-to-office-365-emails-with-powershell/#create-an-office-365-signature and modified it to my liking.

 

[bEGIN CODE]

#import the active directory module which is needed for Get-ADUser

import-module activedirectory

 

#set folder location for files, the folder must already exist

$save_location = 'c:\Signatures\'

 

#$users = Get-ADUser -filter * -searchbase "OU=Testing,OU=Staff,OU=Test Users,DC=bigcheese,DC=com" -Properties * -Credential bigcheese\admin -Server bigcheese.com

$users = Get-ADUser -filter {(EmailAddress -like "*") -and (Enabled -eq "True")} -searchbase "OU=SomeOU,DC=YourDomain,DC=com" -Properties *

 

foreach ($user in $users) {

$account_name = "$($User.sAMAccountName)"

$full_name = "$($user.GivenName) $($User.sn)$($User.extensionAttribute1)"

$job_title = "$($User.title)"

$comp = "$($User.company)"

$phone = "$($User.telephoneNumber)"

$mobile = "$($User.mobile)"

$fax = "$($User.facsimileTelephoneNumber)"

$email = "$($User.emailaddress)"

$street = "$($User.streetAddress)"

$city = "$($User.l)"

$state = "$($User.st)"

$zipcode = "$($User.postalCode)"

$mobileyes = "$($Null)"

$faxyes = "$($Null)"

$mobileAndFax = "$($Null)"

$noMobileOrFax = "$($Null)"

 

if ($mobile)

{$mobileyes = "1"}

else {}

if ($fax)

{$faxyes = "2"}

else {}

if ($mobileyes+$faxyes -eq "12")

{$mobileAndFax = "3"}

else {}

if ($mobileyes+$faxyes -eq "")

{$noMobileOrFax = "4"}

else {}

 

if ($MobileAndFax -eq "3")

{

#We need to construct and write the html signature file

$output_file = $save_location + $account_name + ".htm"

Write-Host "Now attempting to create signature html file for " $full_name

"<span style=`"font-family: calibri,sans-serif;`"><strong>" + $full_name + "</strong><br />", $job_title + "<br />", "<a href=`"http://www.somewebsite.com`" target=`"_blank`">$comp</a>" + "<br />", $street + "<br />", $city + ", " + $state + ", " + $zipcode + "<br />", "<span style=`"font-weight: bold;`">" + "Ph:" + "</span>" + " " + $phone + "<br />", "<span style=`"font-weight: bold;`">" + "Cell:" + "</span>" + " " + $mobile + "<br />", "<span style=`"font-weight: bold;`">" + "Fax:" + "</span>" + " " + $fax + "<br />", "<a href=`"mailto: $Email`">$Email</a>" + "<br />", "</span><br />" | Out-File $output_file

}

elseif ($mobileYes -eq "1")

{

#We need to construct and write the html signature file

$output_file = $save_location + $account_name + ".htm"

Write-Host "Now attempting to create signature html file for " $full_name

"<span style=`"font-family: calibri,sans-serif;`"><strong>" + $full_name + "</strong><br />", $job_title + "<br />", "<a href=`"http://www.somewebsite.com`" target=`"_blank`">$comp</a>" + "<br />", $street + "<br />", $city + ", " + $state + ", " + $zipcode + "<br />", "<span style=`"font-weight: bold;`">" + "Ph:" + "</span>" + " " + $phone + "<br />", "<span style=`"font-weight: bold;`">" + "Cell:" + "</span>" + " " + $mobile + "<br />", "<a href=`"mailto: $Email`">$Email</a>" + "<br />", "</span><br />" | Out-File $output_file

}

elseif ($faxyes -eq "2")

{

#We need to construct and write the html signature file

$output_file = $save_location + $account_name + ".htm"

Write-Host "Now attempting to create signature html file for " $full_name

"<span style=`"font-family: calibri,sans-serif;`"><strong>" + $full_name + "</strong><br />", $job_title + "<br />", "<a href=`"http://www.somewebsite.com`" target=`"_blank`">$comp</a>" + "<br />", $street + "<br />", $city + ", " + $state + ", " + $zipcode + "<br />", "<span style=`"font-weight: bold;`">" + "Ph:" + "</span>" + " " + $phone + "<br />", "<span style=`"font-weight: bold;`">" + "Fax:" + "</span>" + " " + $fax + "<br />", "<a href=`"mailto: $Email`">$Email</a>" + "<br />", "</span><br />" | Out-File $output_file

}

elseif ($NoMobileOrFax -eq "4")

{

#We need to construct and write the html signature file

$output_file = $save_location + $account_name + ".htm"

Write-Host "Now attempting to create signature html file for " $full_name

"<span style=`"font-family: calibri,sans-serif;`"><strong>" + $full_name + "</strong><br />", $job_title + "<br />", "<a href=`"http://www.somewebsite.com`" target=`"_blank`">$comp</a>" + "<br />", $street + "<br />", $city + ", " + $state + ", " + $zipcode + "<br />", "<span style=`"font-weight: bold;`">" + "Ph:" + "</span>" + " " + $phone + "<br />", "<a href=`"mailto: $Email`">$Email</a>" + "</span><br />" | Out-File $output_file

}

else {}

}

[END CODE]

 

If you want to add a logo to your signature, add logo variable like:

$logo = "$($User.wWWHomePage)"

 

Then, in each Active Directory user account, use the Webpage field to put a path to a logo (the full path) like: http://www.somewebsite.com/images/companylogo.png

 

Lastly, towards the end of each of the "<span style=" lines after the email section ("<a href=`"mailto: $Email`">$Email</a>"), add this: , "<img alt=`"Corporate Logo`" border=`"0`" height=`"108`" src=`"" + $logo + "`" width=`"173`" />", "</span><br />" | Out-File $output_file

 

Adjust the height and width to the size of your logo.

 

To add the newly created signature files to OWA, run the following code in a ps1 file in Exchange Management Shell:

[bEGIN CODE]

$mailboxes = Get-Mailbox

$mailboxes| foreach {$file= "C:\signatures" + ($_.alias) + ".htm"; Set-MailboxMessageConfiguration -identity $_.alias -SignatureHtml "$(Get-Content -Path $file -ReadCount 0)" -autoaddsignature $true }

[END CODE]

 

Hope this helps!

Edited by BrettH
adamj84

Posted (edited)

Hi guys - this post is awesome! have got the main signature working, need to spend a bit more time to sort the OWA out afterwards but having it all here couldnt be easier! :)

 

Not all fields are populated in AD, and I would like to put job titles, and DDI's in some signatures, where the data has been input. I am sure it can be done from seeing bits on other places, but how can I set a field name to delete itself if the AD data field is empty? and thus only complete data shows up on end users signatures?

 

Thank you

Adam

 

...Taking a look at the OWA script, I did think that was a replacement for the one up top but doesnt look it? so not sure how to sort the hide empty fields...?

Edited by adamj84
BrettH

Posted

Hi guys - this post is awesome! have got the main signature working, need to spend a bit more time to sort the OWA out afterwards but having it all here couldnt be easier! :)

 

Not all fields are populated in AD, and I would like to put job titles, and DDI's in some signatures, where the data has been input. I am sure it can be done from seeing bits on other places, but how can I set a field name to delete itself if the AD data field is empty? and thus only complete data shows up on end users signatures?

 

Thank you

Adam

 

...Taking a look at the OWA script, I did think that was a replacement for the one up top but doesnt look it? so not sure how to sort the hide empty fields...?

 

Hello adamj84,

 

I would have responded earlier, but did not receive notification. Here's what I did. This is extracted from the Set-OutlookSignature.ps1 script that I use. This is an example of how I removed a cell phone number from the Signature template file, a .docx file created in Word 2010. This is from the part of the script where it's looking for text matches to replace with the valid info. $ADMobile is defined earlier in the script as "$ADMobile = $ADUser.mobile" (without the quotes).

###Begin Code###

#If a Cell number exists for the end user, add it to their signature. Otherwise, remove the Cell line from the template.

if ($ADMobile -ne $null)

{

$FindText = "mobileNumber"

$ReplaceText = $ADMobile.ToString()

$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )

}

else

{

$FindText = "Cell: mobileNumber"

$ReplaceText = "^p"

$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )

$FindText = "^p^p"

$ReplaceText = ""

$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )

}

###End Code###

 

The above code will look in the .docx file for a line with text "Cell: mobileNumber" and remove it if it doesn't an associated value.

 

Kind Regards,

Brett

adamj84

Posted

Thanks for this Brett :) I'll get that added now see if I can get that working here.

 

I have had a couple of issues with the signature and wondered if you had any ideas?

 

1. Some users have found their auto signatures arent the template at all, and that some word doc they have opened at some point is now their signature until I amend the template and it recreates, which I expect.

 

2. 1 user at the moment has their signature recreate OK 1 time, and then the next time the signature goes to create for any changes, it doesnt pull through their AD creds... the template is there but with the placeholders? all very odd stuff!

 

Thanks,

Adam

BrettH

Posted

Thanks for this Brett :) I'll get that added now see if I can get that working here.

 

I have had a couple of issues with the signature and wondered if you had any ideas?

 

1. Some users have found their auto signatures arent the template at all, and that some word doc they have opened at some point is now their signature until I amend the template and it recreates, which I expect.

 

2. 1 user at the moment has their signature recreate OK 1 time, and then the next time the signature goes to create for any changes, it doesnt pull through their AD creds... the template is there but with the placeholders? all very odd stuff!

 

Thanks,

Adam

 

Let me first explain that my post on Sept 8th was all about a script for creating OWA signatures. It does not have anything to do with the Outlook Signature template running from the domain. The OWA signature script should be run anytime a new user is added or anytime you just want to make sure that signatures are accurate.

 

I'm sorry, I don't really have an answer for you regarding your two points, but I'll make a couple suggestions . On point one, I would just say to make sure that the only thing in the signature folder is the template that you want them to use. If you put anything else in there, the script basically copies the whole directory to the user's profile. There might be some complication there if you have anything besides the template file (I.E., backup folders/files). For point two, perhaps you need to specify in your group policy settings to make it wait for the scripts to complete before ending (Synchronous). It might be terminating too soon and thus not completing the script.

 

Kind Regards,

Brett

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...