-
-
Save palikhov/14daf52b31ebfedcd143020160f8644e to your computer and use it in GitHub Desktop.
Outlook signature distribution logon script - Template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Global variables | |
Set objShell = CreateObject("WScript.Shell") | |
Set objUser = CreateObject("ADSystemInfo") | |
Set objCurrentUser = GetObject("LDAP://" & objUser.UserName) | |
' Outlook signature location, for Outlook 2010, 2013 & 2016 | |
appData = objShell.ExpandEnvironmentStrings("%APPDATA%") | |
outlookSignatures = appData & "\Microsoft\Signatures" | |
' Signature locations | |
source = "\\[sharename]\signatures" | |
sourceSig = source & "\[signaturefilename].htm" | |
destinationSig = outlookSignatures & "\[signaturefilename].htm" | |
processSig = False | |
Set fso = CreateObject("Scripting.FileSystemObject") | |
'Create missing folders | |
If Not fso.FolderExists(outlookSignatures) Then | |
fso.CreateFolder(outlookSignatures) | |
End If | |
' Copy the source signature if it doesn't exist | |
If Not fso.FileExists(destinationSig) Then | |
fso.CopyFile sourceSig, destinationSig, True | |
processSig = True | |
End If | |
' Copy a logo (could come in handy) | |
If Not fso.FolderExists(outlookSignatures & "\img") Then | |
fso.CreateFolder(outlookSignatures & "\img") | |
End If | |
If Not fso.FileExists(outlookSignatures & "\img\logo.png") Then | |
fso.CopyFile source & "\img\logo.png", outlookSignatures & "\img\logo.png", True | |
End If | |
' Update destination signature if the source was modified | |
Set sourceFile = fso.GetFile(sourceSig) | |
Set destinationFile = fso.GetFile(destinationSig) | |
If sourceFile.DateLastModified > destinationFile.DateLastModified Then | |
fso.CopyFile sourceSig, destinationSig, True | |
processSig = True | |
End If | |
' If we need to process the signature let's build it | |
If processSig Then | |
Set desinationFileContent = fso.OpenTextFile(destinationSig, 1) | |
signatureContent = desinationFileContent.ReadAll | |
desinationFileContent.Close | |
' Replace the available placeholders (Format: %%placeholder%%) | |
signatureContent = Replace(signatureContent, "%%FirstName%%", objCurrentUser.FirstName) | |
signatureContent = Replace(signatureContent, "%%LastName%%", objCurrentUser.LastName) | |
signatureContent = Replace(signatureContent, "%%Title%%", objCurrentUser.Title) | |
signatureContent = Replace(signatureContent, "%%PhoneNumber%%", objCurrentUser.TelephoneNumber) | |
signatureContent = Replace(signatureContent, "%%MobileNumber%%", objCurrentUser.Mobile) | |
signatureContent = Replace(signatureContent, "%%Email%%", objCurrentUser.Mail) | |
Set desinationFileContent = fso.OpenTextFile(destinationSig, 2) | |
desinationFileContent.WriteLine signatureContent | |
desinationFileContent.Close | |
' Message to notify the user (uncomment the line below to activate) | |
' WScript.Echo "Your Outlook signature [name] has been updated." | |
End If |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment