Link to home
Start Free TrialLog in
Avatar of mathewsitdept
mathewsitdeptFlag for United States of America

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:
   
 $MSWord = New-Object -comobject word.application
    $EmailOptions = $MSWord.EmailOptions
    $EmailSignature = $EmailOptions.EmailSignature
    $EmailSignature.NewMessageSignature = $SignatureName
    $emailSignature.ReplyMessageSignature = $SignatureName
    $MSWord.Quit

Open in new window


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

Open in new window


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
Avatar of Muhammad Burhan
Muhammad Burhan
Flag of Pakistan image

Avatar of mathewsitdept

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...
ASKER CERTIFIED SOLUTION
Avatar of Muhammad Burhan
Muhammad Burhan
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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'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\<VERSION>\Outlook\Profiles\<PROFILE>\9375CFF0413111d3B88A00104B2A6676\0000000[X]\New Signature
-and-
HKCU:\\Software\Microsoft\Office\<VERSION>\Outlook\Profiles\<PROFILE>\9375CFF0413111d3B88A00104B2A6676\0000000[X]\Reply-Forward 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