Jump to content

Recommended Posts

Posted

Good stuff. Will definitely look at implementing this.

 

We use Gmail and I've got an apps script that sets the signature for webmail but this would be good if it works for g suite/outlook sync users

 

Looking on my phone but in the three reg key lines at the bottom one has a value of signatures and the other two are just signature. Is that correct?

  • Thanks 1
Posted
Good stuff. Will definitely look at implementing this.

 

We use Gmail and I've got an apps script that sets the signature for webmail but this would be good if it works for g suite/outlook sync users

 

Looking on my phone but in the three reg key lines at the bottom one has a value of signatures and the other two are just signature. Is that correct?

 

Let me know how you get on when implementing it! :)

 

Yes they are the correct, the first one sets the name of the folder which we created at the top which is called signatures the other two are saying within that folder use the file called signature. I hope that makes sense. I will make sure I explain that in the read me. I was hoping to get the read me done today but I have a few jobs to do and I am going away till Tuesday (Going to see Dropkick Murphys! woop) so will be hopefully finishing the read me next week.

 

Thank you!

  • 2 weeks later...
Posted

Hi

 

Been playing with this yesterday with great success (Outlook 2010), very simple to setup and use. As a non powershell user, just need to get my head round how to build our formatted signature file from your example (ie integrate into a 3 column formatted table etc) but looks a fun project to get my head round.

 

Thanks for your time and effort in making this public

Andrew

  • Thanks 1
Posted
Hi

 

Been playing with this yesterday with great success (Outlook 2010), very simple to setup and use. As a non powershell user, just need to get my head round how to build our formatted signature file from your example (ie integrate into a 3 column formatted table etc) but looks a fun project to get my head round.

 

Thanks for your time and effort in making this public

Andrew

 

Really happy you had success with this. Also thank you for reporting it worked with 2010, did you have to modify the registry keys for that to work or did it just work? If it just worked I will modify the read me to say it works on 2010.

I am actually in the middle of a slightly improved version that is a little more readable and has a neater query for the user. This was initially a rushed job I needed for my work so slowly doing it how it should have been done.

 

If you have any suggestions as a non-powershell user as to what parts were the most difficult to understand I will ensure those parts are explained better and improved if possible :)

 

Thank you.

Posted
You've just saved me a bunch of development time I think - was going to build something like this but now I don't have to! Will experiment later :)

haha excellent! Glad to have saved someone time as it was a pain for me initially! If you need any help with it at all feel free to ask.

  • Thanks 1
Posted
Really happy you had success with this. Also thank you for reporting it worked with 2010, did you have to modify the registry keys for that to work or did it just work? If it just worked I will modify the read me to say it works on 2010.

 

Just changed the reg keys to reflect Outlook 2010:-

 

# Setting the regkeys for Outlook 2010

if (test-path "HKCU:\\Software\\Microsoft\\Office\\14.0\\Common\\General")

{

get-item -path HKCU:\\Software\\Microsoft\\Office\\14.0\\Common\\General | new-Itemproperty -name Signatures -value signatures -propertytype string -force

get-item -path HKCU:\\Software\\Microsoft\\Office\\14.0\\Common\\MailSettings | new-Itemproperty -name NewSignature -value signature -propertytype string -force

get-item -path HKCU:\\Software\\Microsoft\\Office\\14.0\\Common\\MailSettings | new-Itemproperty -name ReplySignature -value signature -propertytype string -force

Remove-ItemProperty -Path HKCU:\\Software\\Microsoft\\Office\\14.0\\Outlook\\Setup -Name "First-Run"

}

 

With regards to the powershell, I've got my head round what does what, just need to work out how to build the formatted signature.htm file. I'll PM you what I've been tasked to create and you can tell me if it's possible or not :)

 

Thanks again

Andrew

  • Thanks 1
Posted
Just changed the reg keys to reflect Outlook 2010:-

 

# Setting the regkeys for Outlook 2010

if (test-path "HKCU:\\Software\\Microsoft\\Office\\14.0\\Common\\General")

{

get-item -path HKCU:\\Software\\Microsoft\\Office\\14.0\\Common\\General | new-Itemproperty -name Signatures -value signatures -propertytype string -force

get-item -path HKCU:\\Software\\Microsoft\\Office\\14.0\\Common\\MailSettings | new-Itemproperty -name NewSignature -value signature -propertytype string -force

get-item -path HKCU:\\Software\\Microsoft\\Office\\14.0\\Common\\MailSettings | new-Itemproperty -name ReplySignature -value signature -propertytype string -force

Remove-ItemProperty -Path HKCU:\\Software\\Microsoft\\Office\\14.0\\Outlook\\Setup -Name "First-Run"

}

 

With regards to the powershell, I've got my head round what does what, just need to work out how to build the formatted signature.htm file. I'll PM you what I've been tasked to create and you can tell me if it's possible or not :)

 

Thanks again

Andrew

Thank you for that, I will add those regkeys to the script and do a check for them so it works with 2010 as well! And yeah please do I will help you sort it out. I am at work currently so my replies might randomly get delayed haha.

Posted
Brilliant, thanks! Currently using O365 mail flow rule but it’s not pretty. This will come in very handy.

Glad it is working for you :)

Yeah Mailflow can have some unexpected results when it comes to email threads ending up with a lot of signatures at the bottom of the email and stuff haha.

Posted
I think this may come in very handy at some point in the future so I’ll thank you in advance.

 

I hope it does, PM me if you need any help with it.

  • 3 weeks later...
  • 8 months later...
Posted

I have updated the script to allow extra information based on a security group :) The example in the script is if you are a member of IT team it will add a line to the signature about contacting the IT Helpdesk :) I added this a while ago but forgot to update the link in here.

 

I will also be updating the signature script to use a nicer format soon and will update you guys on here when I have uploaded.

 

Thank you.

  • 1 month later...
Posted (edited)
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:

 

[ATTACH=CONFIG]53111[/ATTACH]

 

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

 

--

 

Looks good,

 

I've been working on a signature myself and my only struggle is execution, i've set it up as a powershell script via Group Policy to run every time a user logs in but when it gets to the desktop, it asks me to save a "Normal.dotm" word file or something like that.

 

IMG_20200213_151144_LI.jpgIMG_20200213_151154_LI.jpgIMG_20200214_100202_LI.jpg

 

I was wondering if i could get a 2nd opinion? I've left my code below if you or anyone is interested:

 

 

#Custom variables $SignatureName = 'Signature' $SigSource = "\\PREP-AD02\AD Resources$\Signature.docx" #Path to the *.docx file$SignatureVersion = "1.8" #Change this if you have updated the signature. If you do not change it, the script will quit after checking for the version already on the machine $ForceSignature = '1' #Set to 1 if you don't want the users to be able to change signature in Outlook #Environment variables $AppData=(Get-Item env:appdata).value $SigPath = '\Microsoft\Signatures' #Path to signatures. $LocalSignaturePath = $AppData+$SigPath $RemoteSignaturePathFull = $SigSource #Check signature path (needs to be created if a signature has never been created for the profile if (-not(Test-Path -path $LocalSignaturePath)) { New-Item $LocalSignaturePath -Type Directory} #Copy version file If (-not(Test-Path -Path $LocalSignaturePath\$SignatureVersion)) { If (Test-Path HKCU:'\Software\Microsoft\Office\16.0') { $ForceKeyPathReply = (Get-ItemProperty 'HKCU:\Software\Microsoft\Office\16.0\Common\MailSettings').ReplySignature -eq $null $ForceKeyPathNew = (Get-ItemProperty 'HKCU:\Software\Microsoft\Office\16.0\Common\MailSettings').NewSignature -eq $null If ($ForceKeyPathReply -eq $False) {Remove-ItemProperty -path 'HKCU:\Software\Microsoft\Office\14.0\Common\MailSettings' -name ReplySignature} Else {Write-Host "The reg value does not exist"} If ($ForceKeyPathNew -eq $False) {Remove-ItemProperty -path 'HKCU:\Software\Microsoft\Office\14.0\Common\MailSettings' -name NewSignature} Else {Write-Host "The reg value does not exist"} } If ($ForceSignature -eq '1') { Get-ChildItem -Path $LocalSignaturePath -Recurse | foreach {remove-item $_.fullname -recurse -force -ErrorAction SilentlyContinue} } New-Item -Path $LocalSignaturePath\$SignatureVersion -ItemType Directory } Elseif (Test-Path -Path $LocalSignaturePath\$SignatureVersion) { break } #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 $ADTelePhoneNumber = $ADUser.TelephoneNumber $ADModify = $ADUser.whenChanged #Copy signature templates from source 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 $FindText = "DisplayName"$ReplaceText = $ADDisplayName.ToString()$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll ) #Title $FindText = "Title" $ReplaceText = $ADTitle.ToString() $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll ) #Email Address $FindText = "e-mail" $ReplaceText = $ADEmailAddress.ToString() $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll ) #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 2016 signature If (Test-Path HKCU:Software\Microsoft\Office\16.0) { If ($ForceSignature -eq '0') { $ForceKeyPathReply = (Get-ItemProperty 'HKCU:\Software\Microsoft\Office\16.0\Common\MailSettings').ReplySignature -eq $null $ForceKeyPathNew = (Get-ItemProperty 'HKCU:\Software\Microsoft\Office\16.0\Common\MailSettings').NewSignature -eq $null If ($ForceKeyPathReply -eq $False) {Remove-ItemProperty -path 'HKCU:\Software\Microsoft\Office\16.0\Common\MailSettings' -name ReplySignature} Else {Write-Host "The reg value does not exist"} If ($ForceKeyPathNew -eq $False) {Remove-ItemProperty -path 'HKCU:\Software\Microsoft\Office\16.0\Common\MailSettings' -name NewSignature} Else {Write-Host "The reg value does not exist"} $MSWord = New-Object -comobject word.application $EmailOptions = $MSWord.EmailOptions $EmailSignature = $EmailOptions.EmailSignature $EmailSignatureEntries = $EmailSignature.EmailSignatureEntries $EmailSignature.NewMessageSignature=$SignatureName $EmailSignature.ReplyMessageSignature=$SignatureName $MSWord.Quit() } If ($ForceSignature -eq '1') { $MSWord = New-Object -comobject word.application $EmailOptions = $MSWord.EmailOptions $EmailSignature = $EmailOptions.EmailSignature $EmailSignatureEntries = $EmailSignature.EmailSignatureEntries $EmailSignature.NewMessageSignature=$SignatureName $EmailSignature.ReplyMessageSignature=$SignatureName $MSWord.Quit() If (Get-ItemProperty -Name 'NewSignature' -Path HKCU:'\Software\Microsoft\Office\16.0\Common\MailSettings') { } Else { New-ItemProperty HKCU:'\Software\Microsoft\Office\16.0\Common\MailSettings' -Name 'NewSignature' -Value $SignatureName -PropertyType 'String' -Force } If (Get-ItemProperty -Name 'ReplySignature' -Path HKCU:'\Software\Microsoft\Office\16.0\Common\MailSettings') { } Else { New-ItemProperty HKCU:'\Software\Microsoft\Office\16.0\Common\MailSettings' -Name 'ReplySignature' -Value $SignatureName -PropertyType 'String' -Force } } }

 

--

 

Another thing i was wondering was is that if i decided to use your code, would i be able to implement my variables and layout on it as well or does it have to reflect your design? and is there a feature on your code that stops users from editing there own signatures? Sorry if i sound confusing :confused:

Edited by Kelechi93
Posted (edited)

Hello Kelechi93,

 

You are totally free to edit my script to make it how you like, there is nothing in it to stop you :) All I was doing with mine was providing a base line for those that didn't know where to start.

If you like I can sit and help you get it working how you would like for your environment and help you get past the error you are having.

 

I am currently at work and your code post has been formatted badly by the thread, so I when I get home I will copy and paste it into VS Code and take a look as well :) But yes you can use my script and we can totally change it to suite your organisation.

 

Please feel free to PM me if you would like some one to one assistance with this :)

EDIT: Sorry I just realised you meant is there anything stopping the users editing their own signatures after the fact, well we can talk about this, you can allow them to edit their own but you lose the dynamic overwriting of their signature as we would have to use the Apply Once rule on the GPO. Or if you let me know the type of things your users will add we can look at doing it via security groups like I do at my current place of work. We have some users that need a Health and Safety badge and I used a security group so it only adds that badge to those users all contained in the same script :)

Thank you.

Edited by QwertyMash
Posted
Hello Kelechi93,

 

You are totally free to edit my script to make it how you like, there is nothing in it to stop you :) All I was doing with mine was providing a base line for those that didn't know where to start.

If you like I can sit and help you get it working how you would like for your environment and help you get past the error you are having.

 

I am currently at work and your code post has been formatted badly by the thread, so I when I get home I will copy and paste it into VS Code and take a look as well :) But yes you can use my script and we can totally change it to suite your organisation.

 

Please feel free to PM me if you would like some one to one assistance with this :)

EDIT: Sorry I just realised you meant is there anything stopping the users editing their own signatures after the fact, well we can talk about this, you can allow them to edit their own but you lose the dynamic overwriting of their signature as we would have to use the Apply Once rule on the GPO. Or if you let me know the type of things your users will add we can look at doing it via security groups like I do at my current place of work. We have some users that need a Health and Safety badge and I used a security group so it only adds that badge to those users all contained in the same script :)

Thank you.

 

A Gentlemen and a Scholar, thanks for looking into this for me. :troll:

 

Just to be clear, on the Active Directory side of things, i've already populated the fields, i just need it to work. I've set it up already so that the staff can't change there own signature's and only go by what we've set up for them (some teachers like to "exaggerate" there job role :lie:). But the results i'm getting is that the script is running, but the signature is missing:

 

IMG_20200214_145123_LI.jpg

 

That's my struggle right now and worst-case i'm thinking about changing up the code completely or seeing if someone else can spot something that i haven't :(

Posted
A Gentlemen and a Scholar, thanks for looking into this for me. :troll:

 

Just to be clear, on the Active Directory side of things, i've already populated the fields, i just need it to work. I've set it up already so that the staff can't change there own signature's and only go by what we've set up for them (some teachers like to "exaggerate" there job role :lie:). But the results i'm getting is that the script is running, but the signature is missing:

 

[ATTACH=CONFIG]57078[/ATTACH]

 

That's my struggle right now and worst-case i'm thinking about changing up the code completely or seeing if someone else can spot something that i haven't :(

 

I will look at your script today :) I have just saved it, I just need to reformat it, if you are free today to send me the actual script file that would save me some time :)

 

We will get you sorted in no time sir :)

Posted
I will look at your script today :) I have just saved it, I just need to reformat it, if you are free today to send me the actual script file that would save me some time :)

 

We will get you sorted in no time sir :)

 

Signature.ps1

 

There you go sir.

Posted
[ATTACH]57095[/ATTACH]

 

There you go sir.

After looking at your script sir, I recommend we consider implementing my script :) I will help you do it if you like we can get it to look how you like.

I see yours is using a reconfigure docx and doing a replace in the document to build a new signature and using word to do all the saves, this is a bit more intense than it needs to be :)

  • Thanks 1
Posted
After looking at your script sir, I recommend we consider implementing my script :) I will help you do it if you like we can get it to look how you like.

I see yours is using a reconfigure docx and doing a replace in the document to build a new signature and using word to do all the saves, this is a bit more intense than it needs to be :)

 

I'm open to that, as long as i'm able get the design to scale since it's already been approved by the Head and the Marketing Manager, what would i need to do? would you like me to PM you?

Posted
I'm open to that, as long as i'm able get the design to scale since it's already been approved by the Head and the Marketing Manager, what would i need to do? would you like me to PM you?

 

I will PM you :) Sorry for delayed reply I have been ill.

Posted
I will PM you :) Sorry for delayed reply I have been ill.

 

Signature.docx

 

design.PNG

 

Hey sorry, the inbox for some strange reason, won't let me unload attachments so i've given you a screenshot and the word document version.

 

Thanks again, :o

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



  • 149 What is your preferred operating system (PC)

    1. 1. Operating systems:


      • MacOS
      • Windows 10
      • Windows 11
      • Windows Vista
      • ChromeOS
      • Other (reply)

×
×
  • Create New...