Link to home
Create AccountLog in
Avatar of jacksparrownz
jacksparrownz

asked on

Exchange VBScript signature help

Hi, can someone help me out with a VBScript for signature in Exchange 2007? I have no clue how to make a script.. I want the signature to be added to all NEW EMAILS, and not on reply.
This is for all Exchange users in our AD. Will distribute it with GPO..

All info that I want to get from AD is in <>. I want space in front of all lines like below.

Font type: Arial
Size: 8
Fullname = Bold

I want the template to be like this:



Best regards,

<fullname>
 <title>

logo(119x28px)

 <street>
 P.O. Box <P.O. Box>,
 <zip/postal code>
 Phone #: + 41 <home>
 Mobile #: + 41 <mobile
 http://www.ourcompany.com


(http: should be a hyperlink)
Avatar of Suliman Abu Kharroub
Suliman Abu Kharroub
Flag of Jordan image

If signature is not needed for replies, you can use a transport rule to get it work:

http://www.expta.com/2010/06/using-dynamic-signatures-in-exchange.html
In the rule exception add a new exception: when subject contains "RE:".
Avatar of jacksparrownz
jacksparrownz

ASKER

What if I want a simple signatures for reply?
Ex:
<fullname>
<mobile>
Possible but not recommended.. Because the rule will append the signature  at the end of the  whole conversation not the last sent email.


See comments in the provided link .
Yep, that is what I was affraid of.. Thats the main reason to why I want to have it scripted in VB, and not added to transport as a "disclaimer"..
SOLUTION
Avatar of Suliman Abu Kharroub
Suliman Abu Kharroub
Flag of Jordan image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
ASKER CERTIFIED SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Powershell will work fine :) Will check these solutions and see if Im able to make something out of it.. As said earlier. I cant code :/
###########################################################################”
#
# NAME: Set-OutlookSignature.ps1
#
# AUTHOR: Jan Egil Ring
# Modifications by Darren Kattan
#
# COMMENT: Script to create an Outlook signature based on user information from Active Directory.
# Adjust the variables in the “Custom variables”-section
# Create an Outlook-signature from Microsoft Word (logo, fonts etc) and copy this signature to \\domain\NETLOGON\sig_files\$CompanyName\$CompanyName.docx
#	 This script supports the following keywords:
#	 DisplayName
#	 Title
#	 Email
#
#    See the following blog-posts for more information: 
#    http://blog.powershell.no/2010/01/09/outlook-signature-based-on-user-information-from-active-directory
#    http://www.immense.net/deploying-unified-email-signature-template-outlook
#
# Tested on Office 2003, 2007 and 2010
#
# You have a royalty-free right to use, modify, reproduce, and
# distribute this script file in any way you find useful, provided that
# you agree that the creator, owner above has no warranty, obligations,
# or liability for such use.
#
# VERSION HISTORY:
# 1.0 09.01.2010 – Initial release
# 1.1 11.09.2010 – Modified by Darren Kattan
#	- Removed bookmarks. Now uses simple find and replace for DisplayName, Title, and Email.
#	- Email address is generated as a link
#	- Signature is generated from a single .docx file
#	- Removed version numbers for script to run. Script runs at boot up when it sees a change in the “Date Modified” property of your signature template.
#
#
###########################################################################”

#Custom variables
$CompanyName = ‘OurCompanyName’
$DomainName = ‘our.domainname.local’

$SigSource = “\\$DomainName\netlogon\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 = ’1' #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
$ADStreet = $ADuser.Street
$ADPOBox = $ADUser.POBox
$ADZipCode = $ADUser.ZipCode
$ADCity = $ADUser.City
$ADHomePhoneNumber = $ADUser.HomePhoneNumber
$ADMobileNumber = $ADUser.MobileNumber

#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 = $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 -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 = “Street”
$ReplaceText = $ADStreet.ToString()
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,	$MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap,	$Format, $ReplaceText, $ReplaceAll	)

$FindText = “POBox”
$ReplaceText = $ADPOBox.ToString()
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,	$MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap,	$Format, $ReplaceText, $ReplaceAll	)

$FindText = “ZipCode”
$ReplaceText = $ADZipCode.ToString()
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,	$MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap,	$Format, $ReplaceText, $ReplaceAll	)

$FindText = “City”
$ReplaceText = $ADCity.ToString()
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,	$MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap,	$Format, $ReplaceText, $ReplaceAll	)


$MSWord.Selection.Find.Execute(“Email”)

$MSWord.ActiveDocument.Hyperlinks.Add($MSWord.Selection.Range, “mailto:”+$ADEmailAddress.ToString(), $missing, $missing, $ADEmailAddress.ToString())

$MSWord.ActiveDocument.Save()
$saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], “wdFormatHTML”);
[ref]$BrowserLevel = “microsoft.office.interop.word.WdBrowserLevel” -as [type]

$MSWord.ActiveDocument.WebOptions.OrganizeInFolder = $true
$MSWord.ActiveDocument.WebOptions.UseLongFileNames = $true
$MSWord.ActiveDocument.WebOptions.BrowserLevel = $BrowserLevel::wdBrowserLevelMicrosoftInternetExplorer6
$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+”.rtf”
$MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$saveFormat)

$path = $LocalSignaturePath+’\'+$CompanyName+”.txt”
$MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$SaveFormat::wdFormatText)
$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}

Open in new window


Do this look ok compared to what I want in my template? I have created the .docx and .htm template files with bookmarkes..

Should I remove this from the code since I dont want to add email to the signature?

$MSWord.Selection.Find.Execute(“Email”)

$MSWord.ActiveDocument.Hyperlinks.Add($MSWord.Selection.Range, “mailto:”+$ADEmailAddress.ToString(), $missing, $missing, $ADEmailAddress.ToString())

Open in new window

I've added your fields to the script. Just make sure your variable names match the ones in the script. You don't need to remove any lines. If you have not defined some variables, they will just be ignored.

###########################################################################"
#
# NAME: Set-OutlookSignature.ps1
#
# AUTHOR: Jan Egil Ring
# Modifications by Darren Kattan
# Further Modifications by Jamie McKillop - http://jamiemckillop.wordpress.com/
#
# COMMENT: Script to create an Outlook signature based on user information from Active Directory.
#          Adjust the variables in the "Custom variables"-section
#          Create an Outlook-signature from Microsoft Word (logo, fonts etc) and copy this signature to \\domain\NETLOGON\sig_files\$CompanyName\$CompanyName.docx
#		   This script supports the following keywords:
#		   	DisplayName
#			Title
#			Email
#          See the following blog-post for more information: http://blog.crayon.no/blogs/janegil/archive/2010/01/09/outlook-signature-based-on-user-information-from-active-directory.aspx
#
#          Tested on Office 2003,2007 and 2010
#
# You have a royalty-free right to use, modify, reproduce, and
# distribute this script file in any way you find useful, provided that
# you agree that the creator, owner above has no warranty, obligations,
# or liability for such use.
#
# VERSION HISTORY:
# 1.0 09.01.2010 - Initial release
# 1.1 11.09.2010 - Modified by Darren Kattan
#	- Removed bookmarks. Now uses simple find and replace for DisplayName, Title, and Email.
#	- Email address is generated as a link
#	- Signature is generated from a single .docx file
#	- Removed version numbers for script to run. Script runs at boot up when it sees a change in the "Date Modified" property of your signature template.
# 1.11 11.15.2010 - Revised by Darren Kattan
#   - Fixed glitch with text signatures
# 1.2 07.06.2012 - Revised by Jamie McKillop
#   - Modified script so that Force Signature settings are set on first run of script
#	- Added variables to allow setting of default signature on creation of signature but not force the signature on each script run
#	- Used variables defined in script for $ForceSignatureNew and $ForceSignatureReplyForward instead of pulling values from the registry
#
###########################################################################"
#Custom variables

$CompanyName = ''
$DomainName = ''
$SigSource = "\\$DomainName\netlogon\sig_files\$CompanyName"
$ForceSignatureNew = '1' #When the signature is forced it sets the default signature for new messages each time the script runs. 0 = no force, 1 = force
$ForceSignatureReplyForward = '1' #When the signature is forced it sets the default signature for reply/forward messages each time the script runs. 0 = no force, 1 = force
$SetSignatureNew = '1' #Determines wheter to set the signature as the default for new messages on first run. This is overridden if $ForceSignatureNew = 1. 0 = don't set, 1 = set
$SetSignatureReplyForward = '1' #Determines wheter to set the signature as the default for reply/forward messages on first run. This is overridden if $ForceSignatureReplyForward = 1. 0 = don't set, 1 = set

#Environment variables
$AppData=(Get-Item env:appdata).value
$SigPath = '\Microsoft\Signatures'
$LocalSignaturePath = $AppData+$SigPath

if (!(Test-Path -path $LocalSignaturePath)) {
	New-Item $LocalSignaturePath -Type Directory
}

$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()
$ADDisplayName = $ADUser.DisplayName
$ADEmailAddress = $ADUser.mail
$ADTitle = $ADUser.title
$ADFax = $ADUser.facsimileTelephoneNumber
$ADTelePhoneNumber = $ADUser.TelephoneNumber
$ADMobile = $ADUser.mobile
$ADHomeTelephone = $ADUser.homephone
$ADStreetAddress = $ADUser.streetaddress
$ADPOBox = $ADUser.postofficebox
$ADZip = $ADUser.postalcode

#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
$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

#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 = $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 -com word.application
	$fullPath = $LocalSignaturePath+'\'+$CompanyName+'.docx'
	$MSWord.Documents.Open($fullPath)
	$FindText = "DisplayName"
	$ReplaceText = $ADDisplayName.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 = "Telephone"
	$ReplaceText = $ADTelephoneNumber.ToString()
	$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,	$MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap,	$Format, $ReplaceText, $ReplaceAll	)
	$FindText = "Fax"
	$ReplaceText = $ADFax.ToString()
	$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,	$MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap,	$Format, $ReplaceText, $ReplaceAll	)
	$FindText = "Mobile"
	$ReplaceText = $ADMobile.ToString()
	$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,	$MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap,	$Format, $ReplaceText, $ReplaceAll	)
	$FindText = "HomeTelephone"
	$ReplaceText = $ADHomeTelephone.ToString()
	$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,	$MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap,	$Format, $ReplaceText, $ReplaceAll	)
	$FindText = "StreetAddress"
	$ReplaceText = $ADStreetAddress.ToString()
	$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,	$MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap,	$Format, $ReplaceText, $ReplaceAll	)
	$FindText = "POBox"
	$ReplaceText = $ADPOBox.ToString()
	$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,	$MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap,	$Format, $ReplaceText, $ReplaceAll	)
	$FindText = "ZipCode"
	$ReplaceText = $ADZip.ToString()
	$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,	$MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap,	$Format, $ReplaceText, $ReplaceAll	)
	$MSWord.Selection.Find.Execute("Email")
	$MSWord.ActiveDocument.Hyperlinks.Add($MSWord.Selection.Range, "mailto:"+$ADEmailAddress.ToString(), $missing, $missing, $ADEmailAddress.ToString())
	$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()
	
	#Set signature for new mesages if enabled
	if ($SetSignatureNew -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()
	}
	
	#Set signature for reply/forward messages if enabled
	if ($SetSignatureReplyForward -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()
	}
}

#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
}

#Forcing signature for new messages if enabled
if ($ForceSignatureNew -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 ($ForceSignatureReplyForward -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()
}

Open in new window

Awsome guys. Thanks to both of you I now have a powershell that autogenerates a signature based on my template on userlogin.

I had to customize the script some(add some Strings), but it works fantastic :)
No powershell scripting knowledge is needed, its that easy to use.

*thumbsup*