mathewsitdept
asked on
Powershell Remote Scripting - Email Signature
Hello everyone.
I'm looking for some input on some other possible solutions to setting a default signature in Outlook with PowerShell. I've been able to do this with no issues in a script that executes on user login. I tried to expand the functionality a little in order to allow our help-desk staff to push an email signature to a user from a web console. Everything in the script is working except for the portion of making the signature "available" and setting as the default. I can successfully FORCE the signature, which prevents the end user from being able to switch between multiple signatures. I have several users who need to switch between multiple signatures, so this is not an option for everyone.
The force method just utilizes a few registry keys to force and lock the signature.
In order to make the signature "available" and set as default, its appears that the only method I can find reference to is using Word to do this.
Here is the code snippet for the word portion:
As stated, this will work fine in the login script, or even if our help-desk employee remotes in and executes the script from the end-user's computer. I was hoping to automate the entire process.
If you try to execute the above code remotely, ie. though the use of Invoke-Command or Enter-PSSession I receive an error like this:
I believe this may be related to not having a GUI session. I've seen others refer to this error when trying to automate the conversion of a .DOC file to a .PDF remotely. Neither what I am doing or the document conversion require or produce a graphical interface, but both seem to fail remotely.
I am having no issues on running powershell scripts or commands remotely. I have CredSSP setup and working, this all seems to come down to determining if there is a way other than using Word to set the default signature in Outlook.
Thanks,
Jon
I'm looking for some input on some other possible solutions to setting a default signature in Outlook with PowerShell. I've been able to do this with no issues in a script that executes on user login. I tried to expand the functionality a little in order to allow our help-desk staff to push an email signature to a user from a web console. Everything in the script is working except for the portion of making the signature "available" and setting as the default. I can successfully FORCE the signature, which prevents the end user from being able to switch between multiple signatures. I have several users who need to switch between multiple signatures, so this is not an option for everyone.
The force method just utilizes a few registry keys to force and lock the signature.
In order to make the signature "available" and set as default, its appears that the only method I can find reference to is using Word to do this.
Here is the code snippet for the word portion:
$MSWord = New-Object -comobject word.application
$EmailOptions = $MSWord.EmailOptions
$EmailSignature = $EmailOptions.EmailSignature
$EmailSignature.NewMessageSignature = $SignatureName
$emailSignature.ReplyMessageSignature = $SignatureName
$MSWord.Quit
As stated, this will work fine in the login script, or even if our help-desk employee remotes in and executes the script from the end-user's computer. I was hoping to automate the entire process.
If you try to execute the above code remotely, ie. though the use of Invoke-Command or Enter-PSSession I receive an error like this:
Exception setting "NewMessageSignature": "No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE))"
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException
+ PSComputerName : computer.domain.com
I believe this may be related to not having a GUI session. I've seen others refer to this error when trying to automate the conversion of a .DOC file to a .PDF remotely. Neither what I am doing or the document conversion require or produce a graphical interface, but both seem to fail remotely.
I am having no issues on running powershell scripts or commands remotely. I have CredSSP setup and working, this all seems to come down to determining if there is a way other than using Word to set the default signature in Outlook.
Thanks,
Jon
ASKER
Muhammad,
This script basically does exactly what my script does, and requires the use of Microsoft Word as I described in my original post. Looking for another option...
Thought I could comment on your post, accidently clicked the "Good Comment" choice...
This script basically does exactly what my script does, and requires the use of Microsoft Word as I described in my original post. Looking for another option...
Thought I could comment on your post, accidently clicked the "Good Comment" choice...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I once tried to script signatures like that, but it was a real PITA. Have you considered using a server side signatures instead?
I have found on a few sites a "hybrid" approach can work well. The user has configures their own signature with their name and position, the server tacks on a company logo, contact info, and any legal disclaimers.
I have found on a few sites a "hybrid" approach can work well. The user has configures their own signature with their name and position, the server tacks on a company logo, contact info, and any legal disclaimers.
ASKER
I'm accepting this solution because it led me to figuring out how to set the default signatures via the registry. This wasn't a direct solution, but my script is now working properly. For those who may come across this in a search, the default signatures for Office 2010 and later are set in the registry key located here: HKCU:\\Software\Microsoft\ Office\<VE RSION>\Out look\Profi les\<PROFI LE>\9375CF F0413111d3 B88A00104B 2A6676\000 0000[X]\Ne w Signature
-and-
HKCU:\\Software\Microsoft\ Office\<VE RSION>\Out look\Profi les\<PROFI LE>\9375CF F0413111d3 B88A00104B 2A6676\000 0000[X]\Re ply-Forwar d Signature
The keys are binary byte arrays of UNICODE. The value stored is the name of the Signature you want to be the default.
Thanks everyone,
Jon
-and-
HKCU:\\Software\Microsoft\
The keys are binary byte arrays of UNICODE. The value stored is the name of the Signature you want to be the default.
Thanks everyone,
Jon
http://blog.powershell.no/2010/01/09/outlook-signature-based-on-user-information-from-active-directory/