Here is a powershell script that will create a signature in Outlook from a pre-existing template. It takes information from AD andf inserts it into the siganure, and sets the signature as the default signature.
It is quite simple create a signature in out look with all the formating you need to fit in with your company brand. Set placeholders for name, role and numbers we replace these with the AD settings of the logged on user.
The reason I am posting this I have seen a lot of long and over conplicated solutions to do this that doesn't work half the time. This is just simple and works. And if you need to change the way it looks you just change the source siganture, you dont need to re - write 200 lines of HTML.
I have some validation in the copy I deploy to create a slightly different signature for people who are in a certain department or who dont have a mobile number. If you are a fter this send me a message.
#Setting variables
$strName = $env:username
$name = Get-ADUser $strName -properties * | select -ExpandProperty DisplayName
$role = Get-ADUser $strName -properties * | select -ExpandProperty Description
$ipPhone = Get-ADUser $strName -properties * | select -ExpandProperty telephoneNumber
$mobile = Get-ADUser $strName -properties * | select -ExpandProperty MobilePhone
$filepath = location of your signature
#Sets the signature.
#Finds the word "Name" and replaces it with the users name in Active Directory
#Finds the word "Role" and replaces it with the users Job Title in Active Directory
#Finds the word "number" and replaces it with the users IP phone number in Active Directory
#Finds the word "mobile" and replaces it with the users mobile number in Active Directory
#Test Signature
(gc $filepath) -replace "User",$name -replace "\bRole\b",$role -replace "\bnumber\b",$ipPhone -replace "\bmobile\b", "| m: +44 (0) ""+$mobile" > C:\Users\$env:USERNAME\AppData\Roaming\Microsoft\Signatures\test.txt
#Rich text signature
(gc $filepath) -replace "User",$name -replace "\bRole\b",$role -replace "\bnumber\b",$ipPhone -replace "\bmobile\b", "| m: +44 (0) ""+$mobile" > C:\Users\$env:USERNAME\AppData\Roaming\Microsoft\Signatures\test.rtf
#HTML signature
(gc $filepath) -replace "User",$name -replace "\bRole\b",$role -replace "\bnumber\b",$ipPhone -replace "\bmobile\b", $mobile > C:\Users\$env:USERNAME\AppData\Roaming\Microsoft\Signatures\test.htm
#Sets signature named "test" as default signature
$CompanyName="test"
$MSWord = New-Object -com word.application
$EmailOptions = $MSWord.EmailOptions
$EmailSignature = $EmailOptions.EmailSignature
$EmailSignatureEntries = $EmailSignature.EmailSignatureEntries
$EmailSignature.NewMessageSignature=$CompanyName
$EmailSignature.ReplyMessageSignature=$CompanyName
$MSWord.Quit()
Enjoy!!
No comments:
Post a Comment