Pumpernickel
asked on
Outlook Signature Script
I have a script here that I found online. It doesn't have all of the fields I need it to capture for our outlook signatures. Can someone add these in for me?
displayName
title
company
streetAddress
l (this is an L)
st
postalCode
mail
homePhone
telephoneNumber
facsimileTelephoneNumber
wWWHomePage
displayName
title
company
streetAddress
l (this is an L)
st
postalCode
homePhone
telephoneNumber
facsimileTelephoneNumber
wWWHomePage
<#
.SYNOPSIS
Script to set Outlook 2010/2013 e-mail signature using Active Directory information
.DESCRIPTION
This script will set the Outlook 2010/2013 e-mail signature on the local client using Active Directory information.
The template is created with a Word document, where images can be inserted and AD values can be provided.
Author: Daniel Classon
Version 2.0
.DISCLAIMER
All scripts and other powershell references are offered AS IS with no warranty.
These script and functions are tested in my environment and it is recommended that you test these scripts in a test environment before using in your production environment.
#>
#Custom variables
$SignatureName = 'ale' #insert the company name (no spaces) - could be signature name if more than one sig needed
$SigSource = "" #Path to the *.docx file, i.e "c:\temp\template.docx"
$SignatureVersion = "1.0" #Change this if you have updated the signature. If you do not change it, the script will quit after checking for the version already on the machine
$ForceSignature = '0' #Set to 1 if you don't want the users to be able to change signature in Outlook
#Environment variables
$AppData=(Get-Item env:appdata).value
$SigPath = '\Microsoft\Signaturer'
$LocalSignaturePath = $AppData+$SigPath
$RemoteSignaturePathFull = $SigSource
#Copy version file
If (-not(Test-Path -Path $LocalSignaturePath\$SignatureVersion))
{
New-Item -Path $LocalSignaturePath\$SignatureVersion -ItemType Directory
}
Elseif (Test-Path -Path $LocalSignaturePath\$SignatureVersion)
{
Write-Output "Latest signature already exists"
break
}
#Check signature path (needs to be created if a signature has never been created for the profile
if (-not(Test-Path -path $LocalSignaturePath)) {
New-Item $LocalSignaturePath -Type Directory
}
#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
$ADDescription = $ADUser.description
$ADTelePhoneNumber = $ADUser.TelephoneNumber
$ADMobile = $ADUser.mobile
$ADStreetAddress = $ADUser.streetaddress
$ADCity = $ADUser.l
$ADCustomAttribute1 = $ADUser.extensionAttribute1
$ADModify = $ADUser.whenChanged
#Copy signature templates from source to local Signature-folder
Write-Output "Copying Signatures"
Copy-Item "$Sigsource" $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 -ComObject word.application
$fullPath = $LocalSignaturePath+'\'+$SignatureName+'.docx'
$MSWord.Documents.Open($fullPath)
#User Name $ Designation
$FindText = "DisplayName"
$Designation = $ADCustomAttribute1.ToString() #designations in Exchange custom attribute 1
If ($Designation -ne '') {
$Name = $ADDisplayName.ToString()
$ReplaceText = $Name+', '+$Designation
}
Else {
$ReplaceText = $ADDisplayName.ToString()
}
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )
#Title
$FindText = "Title"
$ReplaceText = $ADTitle.ToString()
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )
#Description
If ($ADDescription -ne '') {
$FindText = "Description"
$ReplaceText = $ADDescription.ToString()
}
Else {
$FindText = " | Description "
$ReplaceText = "".ToString()
}
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )
#$LogInfo += $NL+'Description: '+$ReplaceText
#Street Address
If ($ADStreetAddress -ne '') {
$FindText = "StreetAddress"
$ReplaceText = $ADStreetAddress.ToString()
}
Else {
$FindText = "StreetAddress"
$ReplaceText = $DefaultAddress
}
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )
#City
If ($ADCity -ne '') {
$FindText = "City"
$ReplaceText = $ADCity.ToString()
}
Else {
$FindText = "City"
$ReplaceText = $DefaultCity
}
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )
#Telephone
If ($ADTelephoneNumber -ne "") {
$FindText = "TelephoneNumber"
$ReplaceText = $ADTelephoneNumber.ToString()
}
Else {
$FindText = "TelephoneNumber"
$ReplaceText = $DefaultTelephone
}
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )
#Mobile
If ($ADMobile -ne "") {
$FindText = "MobileNumber"
$ReplaceText = $ADMobile.ToString()
}
Else {
$FindText = "| Mob MobileNumber "
$ReplaceText = "".ToString()
}
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )
#Save new message signature
Write-Output "Saving signatures"
#Save HTML
$saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatHTML");
$path = $LocalSignaturePath+'\'+$SignatureName+".htm"
$MSWord.ActiveDocument.saveas([ref]$path, [ref]$saveFormat)
#Save RTF
$saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatRTF");
$path = $LocalSignaturePath+'\'+$SignatureName+".rtf"
$MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$saveFormat)
#Save TXT
$saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatText");
$path = $LocalSignaturePath+'\'+$SignatureName+".txt"
$MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$SaveFormat)
$MSWord.ActiveDocument.Close()
$MSWord.Quit()
#Office 2010
If (Test-Path HKCU:'\Software\Microsoft\Office\14.0')
{
If ($ForceSignature -eq '1')
{
Write-Output "Setting signature for Office 2010 as forced"
New-ItemProperty HKCU:'\Software\Microsoft\Office\14.0\Common\MailSettings' -Name 'ReplySignature' -Value $SignatureName -PropertyType 'String' -Force
New-ItemProperty HKCU:'\Software\Microsoft\Office\14.0\Common\MailSettings' -Name 'NewSignature' -Value $SignatureName -PropertyType 'String' -Force
}
else
{
Write-Output "Setting Office 2010 signature as available"
$MSWord = New-Object -comobject word.application
$EmailOptions = $MSWord.EmailOptions
$EmailSignature = $EmailOptions.EmailSignature
$EmailSignatureEntries = $EmailSignature.EmailSignatureEntries
}
}
#Office 2013 signature
If (Test-Path HKCU:Software\Microsoft\Office\15.0)
{
Write-Output "Setting signature for Office 2013"
If ($ForceSignature -eq '0')
{
Write-Output "Setting Office 2013 as available"
$MSWord = New-Object -ComObject word.application
$EmailOptions = $MSWord.EmailOptions
$EmailSignature = $EmailOptions.EmailSignature
$EmailSignatureEntries = $EmailSignature.EmailSignatureEntries
}
If ($ForceSignature -eq '1')
{
Write-Output "Setting signature for Office 2013 as forced"
If (Get-ItemProperty -Name 'NewSignature' -Path HKCU:'\Software\Microsoft\Office\15.0\Common\MailSettings') { }
Else {
New-ItemProperty HKCU:'\Software\Microsoft\Office\15.0\Common\MailSettings' -Name 'NewSignature' -Value $SignatureName -PropertyType 'String' -Force
}
If (Get-ItemProperty -Name 'ReplySignature' -Path HKCU:'\Software\Microsoft\Office\15.0\Common\MailSettings') { }
Else {
New-ItemProperty HKCU:'\Software\Microsoft\Office\15.0\Common\MailSettings' -Name 'ReplySignature' -Value $SignatureName -PropertyType 'String' -Force
}
}
}
ASKER
Does this look correct?
<#
.SYNOPSIS
Script to set Outlook 2010/2013 e-mail signature using Active Directory information
.DESCRIPTION
This script will set the Outlook 2010/2013 e-mail signature on the local client using Active Directory information.
The template is created with a Word document, where images can be inserted and AD values can be provided.
Author: Daniel Classon
Version 2.0
.DISCLAIMER
All scripts and other powershell references are offered AS IS with no warranty.
These script and functions are tested in my environment and it is recommended that you test these scripts in a test environment before using in your production environment.
#>
#Custom variables
$SignatureName = 'ale' #insert the company name (no spaces) - could be signature name if more than one sig needed
$SigSource = "" #Path to the *.docx file, i.e "c:\temp\template.docx"
$SignatureVersion = "1.0" #Change this if you have updated the signature. If you do not change it, the script will quit after checking for the version already on the machine
$ForceSignature = '0' #Set to 1 if you don't want the users to be able to change signature in Outlook
#Environment variables
$AppData=(Get-Item env:appdata).value
$SigPath = '\Microsoft\Signaturer'
$LocalSignaturePath = $AppData+$SigPath
$RemoteSignaturePathFull = $SigSource
#Copy version file
If (-not(Test-Path -Path $LocalSignaturePath\$SignatureVersion))
{
New-Item -Path $LocalSignaturePath\$SignatureVersion -ItemType Directory
}
Elseif (Test-Path -Path $LocalSignaturePath\$SignatureVersion)
{
Write-Output "Latest signature already exists"
break
}
#Check signature path (needs to be created if a signature has never been created for the profile
if (-not(Test-Path -path $LocalSignaturePath)) {
New-Item $LocalSignaturePath -Type Directory
}
#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
$ADDescription = $ADUser.description
$ADTelePhoneNumber = $ADUser.TelephoneNumber
$ADMobile = $ADUser.mobile
$ADStreetAddress = $ADUser.streetaddress
$ADCity = $ADUser.l
$ADCustomAttribute1 = $ADUser.extensionAttribute1
$ADModify = $ADUser.whenChanged
#NEW
$ADCompany = $ADUser.company
$ADStreet = $ADUser.StreetAddress
$ADPostalCode = $ADUser.postalCode
$ADWorkPhone = $ADUser.homePhone
$ADFax = $ADUser.facsimileTelephoneNumber
$ADwww = $ADUser.wWWHomePage
#Copy signature templates from source to local Signature-folder
Write-Output "Copying Signatures"
Copy-Item "$Sigsource" $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 -ComObject word.application
$fullPath = $LocalSignaturePath+'\'+$SignatureName+'.docx'
$MSWord.Documents.Open($fullPath)
#User Name $ Designation
$FindText = "DisplayName"
$Designation = $ADCustomAttribute1.ToString() #designations in Exchange custom attribute 1
If ($Designation -ne '') {
$Name = $ADDisplayName.ToString()
$ReplaceText = $Name+', '+$Designation
}
Else {
$ReplaceText = $ADDisplayName.ToString()
}
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )
#Title
$FindText = "Title"
$ReplaceText = $ADTitle.ToString()
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )
#Description
If ($ADDescription -ne '') {
$FindText = "Description"
$ReplaceText = $ADDescription.ToString()
}
Else {
$FindText = " | Description "
$ReplaceText = "".ToString()
}
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )
#$LogInfo += $NL+'Description: '+$ReplaceText
#Street Address
If ($ADStreetAddress -ne '') {
$FindText = "StreetAddress"
$ReplaceText = $ADStreetAddress.ToString()
}
Else {
$FindText = "StreetAddress"
$ReplaceText = $DefaultAddress
}
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )
#City
If ($ADCity -ne '') {
$FindText = "City"
$ReplaceText = $ADCity.ToString()
}
Else {
$FindText = "City"
$ReplaceText = $DefaultCity
}
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )
#Telephone
If ($ADTelephoneNumber -ne "") {
$FindText = "TelephoneNumber"
$ReplaceText = $ADTelephoneNumber.ToString()
}
Else {
$FindText = "TelephoneNumber"
$ReplaceText = $DefaultTelephone
}
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )
#Mobile
If ($ADMobile -ne "") {
$FindText = "MobileNumber"
$ReplaceText = $ADMobile.ToString()
}
Else {
$FindText = "| Mob MobileNumber "
$ReplaceText = "".ToString()
}
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )
####NEW
#Company
$FindText = "Company"
$ReplaceText = $ADCompany.ToString()
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )
#Street Address
$FindText = "StreetAddress"
$ReplaceText = $ADStreet.ToString()
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )
#Postal Code
$FindText = "PostalCode"
$ReplaceText = $ADTitle.ToString()
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )
#Home Phone
$FindText = "homePhone"
$ReplaceText = $ADWorkPhone.ToString()
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )
#Fax
$FindText = "facsimileTelephoneNumber"
$ReplaceText = $ADFax.ToString()
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )
#Home Page
$FindText = "wWWHomePage"
$ReplaceText = $ADwww.ToString()
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )
#Save new message signature
Write-Output "Saving signatures"
#Save HTML
$saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatHTML");
$path = $LocalSignaturePath+'\'+$SignatureName+".htm"
$MSWord.ActiveDocument.saveas([ref]$path, [ref]$saveFormat)
#Save RTF
$saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatRTF");
$path = $LocalSignaturePath+'\'+$SignatureName+".rtf"
$MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$saveFormat)
#Save TXT
$saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatText");
$path = $LocalSignaturePath+'\'+$SignatureName+".txt"
$MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$SaveFormat)
$MSWord.ActiveDocument.Close()
$MSWord.Quit()
#Office 2010
If (Test-Path HKCU:'\Software\Microsoft\Office\14.0')
{
If ($ForceSignature -eq '1')
{
Write-Output "Setting signature for Office 2010 as forced"
New-ItemProperty HKCU:'\Software\Microsoft\Office\14.0\Common\MailSettings' -Name 'ReplySignature' -Value $SignatureName -PropertyType 'String' -Force
New-ItemProperty HKCU:'\Software\Microsoft\Office\14.0\Common\MailSettings' -Name 'NewSignature' -Value $SignatureName -PropertyType 'String' -Force
}
else
{
Write-Output "Setting Office 2010 signature as available"
$MSWord = New-Object -comobject word.application
$EmailOptions = $MSWord.EmailOptions
$EmailSignature = $EmailOptions.EmailSignature
$EmailSignatureEntries = $EmailSignature.EmailSignatureEntries
}
}
#Office 2013 signature
If (Test-Path HKCU:Software\Microsoft\Office\15.0)
{
Write-Output "Setting signature for Office 2013"
If ($ForceSignature -eq '0')
{
Write-Output "Setting Office 2013 as available"
$MSWord = New-Object -ComObject word.application
$EmailOptions = $MSWord.EmailOptions
$EmailSignature = $EmailOptions.EmailSignature
$EmailSignatureEntries = $EmailSignature.EmailSignatureEntries
}
If ($ForceSignature -eq '1')
{
Write-Output "Setting signature for Office 2013 as forced"
If (Get-ItemProperty -Name 'NewSignature' -Path HKCU:'\Software\Microsoft\Office\15.0\Common\MailSettings') { }
Else {
New-ItemProperty HKCU:'\Software\Microsoft\Office\15.0\Common\MailSettings' -Name 'NewSignature' -Value $SignatureName -PropertyType 'String' -Force
}
If (Get-ItemProperty -Name 'ReplySignature' -Path HKCU:'\Software\Microsoft\Office\15.0\Common\MailSettings') { }
Else {
New-ItemProperty HKCU:'\Software\Microsoft\Office\15.0\Common\MailSettings' -Name 'ReplySignature' -Value $SignatureName -PropertyType 'String' -Force
}
}
}
ASKER
This happens and then a whole bunch of other errors
Sorry, we couldn't find your file. Was it moved, renamed, or deleted? (C:\Users\USERNAMEHERE\AppData\...\UDHG.docx)
At C:\Users\USERNAMEHERE\Desktop\set_outlook_signature\set_outlook_signature.ps1:71 char:1
+ $MSWord.Documents.Open($fullPath)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
ASKER
This is the full set of errors
PS C:\Users\USERNAME\Desktop\set_outlook_signature> C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1
Directory: C:\Users\USERNAME\AppData\Roaming\Microsoft\Signaturer
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 5/3/2016 8:41 AM 1.1
Copying Signatures
Sorry, we couldn't find your file. Was it moved, renamed, or deleted? (C:\Users\USERNAME\AppData\...\UDHG.docx)
At C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1:71 char:1
+ $MSWord.Documents.Open($fullPath)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
You cannot call a method on a null-valued expression.
At C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1:83 char:1
+ $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1:88 char:1
+ $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1:99 char:1
+ $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1:111 char:2
+ $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWhole ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1:122 char:1
+ $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1:133 char:1
+ $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1:144 char:1
+ $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1:150 char:1
+ $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1:155 char:1
+ $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1:160 char:1
+ $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1:165 char:1
+ $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1:170 char:1
+ $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1:175 char:1
+ $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Saving signatures
Unable to find type [Microsoft.Office.Interop.Word.WdSaveFormat].
At C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1:181 char:1
+ $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveForm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Offic...rd.WdSaveFormat:TypeName) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
[ref] cannot be applied to a variable that does not exist.
At C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1:183 char:1
+ $MSWord.ActiveDocument.saveas([ref]$path, [ref]$saveFormat)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (saveFormat:VariablePath) [], RuntimeException
+ FullyQualifiedErrorId : NonExistingVariableReference
Unable to find type [Microsoft.Office.Interop.Word.WdSaveFormat].
At C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1:186 char:1
+ $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveForm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Offic...rd.WdSaveFormat:TypeName) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
[ref] cannot be applied to a variable that does not exist.
At C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1:188 char:1
+ $MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$saveFormat)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (saveFormat:VariablePath) [], RuntimeException
+ FullyQualifiedErrorId : NonExistingVariableReference
Unable to find type [Microsoft.Office.Interop.Word.WdSaveFormat].
At C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1:191 char:1
+ $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveForm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Offic...rd.WdSaveFormat:TypeName) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
[ref] cannot be applied to a variable that does not exist.
At C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1:193 char:1
+ $MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$SaveFormat)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (SaveFormat:VariablePath) [], RuntimeException
+ FullyQualifiedErrorId : NonExistingVariableReference
You cannot call a method on a null-valued expression.
At C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1:194 char:1
+ $MSWord.ActiveDocument.Close()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Setting signature for Office 2010 as forced
New-ItemProperty : Cannot find path 'HKCU:\Software\Microsoft\Office\14.0\Common\MailSettings' because it does not exist.
At C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1:204 char:5
+ New-ItemProperty HKCU:'\Software\Microsoft\Office\14.0\Common\Mai ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (HKCU:\Software\...on\MailSettings:String) [New-ItemProperty], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.NewItemPropertyCommand
New-ItemProperty : Cannot find path 'HKCU:\Software\Microsoft\Office\14.0\Common\MailSettings' because it does not exist.
At C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1:205 char:5
+ New-ItemProperty HKCU:'\Software\Microsoft\Office\14.0\Common\Mai ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (HKCU:\Software\...on\MailSettings:String) [New-ItemProperty], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.NewItemPropertyCommand
Setting signature for Office 2013
Setting signature for Office 2013 as forced
Get-ItemProperty : Cannot find path 'HKCU:\Software\Microsoft\Office\15.0\Common\MailSettings' because it does not exist.
At C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1:243 char:9
+ If (Get-ItemProperty -Name 'NewSignature' -Path HKCU:'\Software\M ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (HKCU:\Software\...on\MailSettings:String) [Get-ItemProperty], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemPropertyCommand
New-ItemProperty : Cannot find path 'HKCU:\Software\Microsoft\Office\15.0\Common\MailSettings' because it does not exist.
At C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1:245 char:5
+ New-ItemProperty HKCU:'\Software\Microsoft\Office\15.0\Common\Mai ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (HKCU:\Software\...on\MailSettings:String) [New-ItemProperty], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.NewItemPropertyCommand
Get-ItemProperty : Cannot find path 'HKCU:\Software\Microsoft\Office\15.0\Common\MailSettings' because it does not exist.
At C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1:247 char:9
+ If (Get-ItemProperty -Name 'ReplySignature' -Path HKCU:'\Software ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (HKCU:\Software\...on\MailSettings:String) [Get-ItemProperty], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemPropertyCommand
New-ItemProperty : Cannot find path 'HKCU:\Software\Microsoft\Office\15.0\Common\MailSettings' because it does not exist.
At C:\Users\USERNAME\Desktop\set_outlook_signature\set_outlook_signature.ps1:249 char:5
+ New-ItemProperty HKCU:'\Software\Microsoft\Office\15.0\Common\Mai ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (HKCU:\Software\...on\MailSettings:String) [New-ItemProperty], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.NewItemPropertyCommand
ASKER
C:\Users\USERNAME\AppData\ Roaming\Mi crosoft\Si gnaturer
Contains the signature template and the 1.0 folder (empty)
Contains the signature template and the 1.0 folder (empty)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
it only don't have following
company
st
postalCode
homePhone
facsimileTelephoneNumber
wWWHomePage
and what you need to do is to define them by defining the variable like follow
$ADCompany = $aduser.company
line 82 to 153 is the playing the signature part
Again, you need to have a outcome to put all of these value into the signature. I won't know what exactly what you want a signature
I probably think you should try this and let me know what problem you face so you probably can learn from it :)