I created this script because it is the 2nd company that there is no pushed signature so that everyone could have a different signature. HR or company sends a mail to everyone saying, this is the layout and fill in the rest. People are adding text or changing fonts.
This this script is pushed via GPO. User Configuration -> Policy -> Windows Settings -> Scripts -> Logon.
Add here the PowerShell script. <last script block is the script>
The script runs every time, but it checks if files exist then stops. if not, it execute.
And had request that some people want to inform the default days that they are working.
So I added an option to it. And then the user can run a batch file pointing to the PowerShell manual.
C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass "\\<AD>\NETLOGON\<location>\Signature.ps1 Aanwezig"
And because people manage shared mailboxes, they also wanted a shared mailbox signature.
C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass "\\<AD>\NETLOGON\<location>\Signature.ps1 Shared"
Here is the full PowerShell script that use Active Directory as source of all info. With this you can manage multiple locations. Mail HTML layout is currently not correct, and not all options are working. (Marked)
I wanted to go further at that moment, but didn’t got the time.
If you have an update that you want to push to everyone, change row 32 (new name) and 35 (to remove)
#################################
### Created by Daag van der Meer
###
###
#################################
################################
# Script Setup Parameters #
# #
# DO NOT EDIT!!! SCROLL DOWN #
# TO FIND THE VARIABLES #
# TO EDIT #
################################
##### Aanwezig and Shared
[CmdletBinding()]
param(
[string]$Running
# When this is filled. It goes to different signature
)
####################################################################################################################
#
# Below this block its the edit Part.
#
#
#
###################################################################################################################
## Set Current Signature name
$SignatureNames = "Signature 2023"
#Set name Old signature to remove.
$OldSignaturenametoremove = "Signature 2022"
#Set Closing Text
$Greetings = "Met vriendelijke groet / Kind regards,"
## Set Adres if different than AD
$Adress1 = "" # EG: Company name
$Adress2 = "" # EG: Street
$Adress3 = "" # EG: Zipcode + City
## Set the default phone (Reception)
$DefaultPhone = "+31 "
#Socials URL, If not needed, Make Blank. ("")
$FacebookURL = "" #https://www.facebook.com/xxx/
$InstagramURL = "" #https://www.instagram.com/xxx
$LinkedinURL = "" #https://www.linkedin.com/company/xxx
$TwitterURL = ""
$YoutubeURL = "" #https://www.youtube.com/xxx
#### The logo's on the internet
$Logo = ""
$FacebookLogo = ""
$InstagramLogo = ""
$LinkedinLogo = ""
$TwitterLogo = ""
$YoutubeLogo = ""
### Tracking URL to count when there is clicked on a Social Icon.Leave blank for none.
$FacebookTrack = "" # EG: https://www.google.com/url?q=https://www.facebook.com/
$InstagramTrack = ""
$LinkedinTrack = ""
$Twittertrack = ""
$YoutubeTrack = ""
### Embedd Logo and socials in the email and not on website
### When not embedded, when webserver is slow or down, outlook can hang. But its easy to change logo for all emails.
### When embedded, the logo's are added as attachement. When there is an update, everyone needs to change signature. RTF file wont be created
###
### Yes Or No
$Embedd = "No"
###############
## Enabled or Disable Changes popup
########
# NOT WORKING YET!!!!
$ADchanges = "Disable"
## Checkdays = Check every x Days
$Checkdays = "30"
##########################################################################################
### Do not change below, Only if you know what to change ######
##########################################################################################
If ($Running -eq "")
{
$TestHTML = Test-Path "$env:APPDATA\microsoft\Signatures\$SignatureNames.htm"
$TestRTF = Test-Path "$env:APPDATA\microsoft\Signatures\$SignatureNames.rtf"
$TestTXT = Test-Path "$env:APPDATA\microsoft\Signatures\$SignatureNames.txt"
}
If ($Running -eq "Test" )
{
$TestHTML = $False
$TestRTF = $False
$TestTXT = $False
}
# Outlook 365 now use online signature default. By creating this regkey it use the local one.
$O365SignatureCheck = Get-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Office\16.0\Outlook\Setup | Select-Object -ExpandProperty DisableRoamingSignaturesTemporaryToggle -erroraction 'silentlycontinue'
If ($O365SignatureCheck -ne '1'){
New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Office\16.0\Outlook\Setup -name DisableRoamingSignaturesTemporaryToggle -Value 1 -PropertyType DWORD | out-null
}
### Check if signature dir is there. If not, create
$Sigdircheck = Test-Path "$env:APPDATA\microsoft\Signatures"
If ($Sigdircheck -eq $False)
{
New-Item -Path "$env:APPDATA\microsoft\" -Name "Signatures" -ItemType "directory"
}
If ($ADchanges -ne "Enabled")
{$daychecker = 0
}
If ($ADchanges -eq "Enabled"){
$ADchecktxt = Test-Path "$env:APPDATA\microsoft\Signatures\$SignatureNames.adcheck.txt"
If ($ADchecktxt -eq $true)
{
### Check if file exist (Last check date)
$Lastcheckfile = Get-ChildItem "$env:APPDATA\microsoft\Signatures\$SignatureNames.adcheck.txt" | Select-Object -ExpandProperty CreationTime
$Datetime = (Get-Date).AddDays( -$Checkdays)
If ($Datetime -gt $Lastcheckfile)
{
Remove-Item "$env:APPDATA\microsoft\Signatures\$SignatureNames.adcheck.txt"
}
}
$daychecker = Test-Path "$env:APPDATA\microsoft\Signatures\$SignatureNames.adcheck.txt"
}
If ($Embedd -eq "Yes" -or $Embedd -eq "No")
{
$O36564check = Test-Path "C:\Program Files\Microsoft Office\root\Office16\WINWORD.EXE"
$O36532check = Test-Path "C:\Program Files (x86)\Microsoft Office\root\Office16\WINWORD.EXE"
If (($O36564check -eq $True) -or ($O36532check -eq $True))
{
$Office365 = $True
}
If (($O36564check -eq $False) -and ($O36532check -eq $False)) {$office365 = $False}
If ($office365 -eq $True)
{
$RTFregkeycheck = test-path HKCU:\Software\Microsoft\Office\16.0\Word\Security\DisableWarningOnIncludeFieldsUpdate
If ($RTFregkeycheck -eq $False)
{
New-ItemProperty -Path HKCU:\Software\Microsoft\Office\16.0\Word\Security -Name DisableWarningOnIncludeFieldsUpdate -Value '1' -PropertyType DWORD -Force | Out-Null
}
}
If ($TestpathO15 -eq $true)
{
$valueExists15 = Get-ItemPropertyValue HKCU:\Software\Microsoft\Office\15.0\Common\General -Name Signatures
If ($valueExists15 -ne "Signatures"){Set-ItemProperty -Path HKCU:\Software\Microsoft\Office\15.0\Common\General -name Signatures -Value Signatures | out-null}
}
If ($TestpathO16 -eq $true)
{
$valueExists16 = Get-ItemPropertyValue HKCU:\Software\Microsoft\Office\16.0\Common\General -Name Signatures
If ($valueExists16 -ne "Signatures"){Set-ItemProperty -Path HKCU:\Software\Microsoft\Office\16.0\Common\General -name Signatures -Value Signatures | out-null}
}
If (($TestHTML -eq $False) -or ($TestRTF -eq $False) -or ($TestTXT -eq $False) -or ($Running -eq "Shared") -or ($Running -eq "aanwezig") -or ($daychecker -eq $False -and $ADchanges -eq "Enabled" ))
{
#Get username
$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
$ADFullname = $ADUser.givenName + $ADUser.sn
$ADTitle = $ADUser.Title
$ADDepartment = $ADUser.Department
$ADMobile = $ADUser.Mobile
$ADFax = $ADUser.facsimileTelephoneNumber
$AdPhone = $ADUser.telephoneNumber
$AdCompany = $ADUser.company
$AdStreet = $ADUser.streetAddress
$AdZip = $ADUser.postalCode
$AdTown = $ADUser.l
$AdCountry = $ADUser.co
#$AdCountry = $ADUser.Country
$ADemail = $ADUser.mail
$ADBox = $ADUser.postOfficeBox
$ADMobileNumber = $ADUser.TelephoneMobile
$ADweb_address = $ADUser.wWWHomePage
IF (($ADchanges -eq "Enabled") -and ($TestTXT -eq $True))
{
$GetName = Get-Content "$env:APPDATA\microsoft\Signatures\$SignatureNames.txt" |Select -Index 1
$GetDepartment = Get-Content "$env:APPDATA\microsoft\Signatures\$SignatureNames.txt" |Select -Index 2
$Getfunction = Get-Content "$env:APPDATA\microsoft\Signatures\$SignatureNames.txt" |Select -Index 3
$GetEmail = Get-Content "$env:APPDATA\microsoft\Signatures\$SignatureNames.txt" |Select -Index 5
$GetPhone = Get-Content "$env:APPDATA\microsoft\Signatures\$SignatureNames.txt" |Select -Index 6
$GetPhone = $GetPhone -replace 'T','' -replace ' ',''
$GetMobile = Get-Content "$env:APPDATA\microsoft\Signatures\$SignatureNames.txt" |Select -Index 7
$GetMobile = $GetMobile -replace 'M','' -replace ' ',''
$AdPhone2 = $AdPhone -replace ' ',''
$ADMobile2 = $ADMobile -replace ' ',''
$Lastline = Get-Content "$env:APPDATA\microsoft\Signatures\$SignatureNames.txt" -Tail 1
If (($Lastline -like "*Werkzaam*") -or ($Lastline -like "*Working*"))
{
$werkzaamheden = $Lastline
}
If ($daychecker -eq $False -and $Running -ne 'aanwezig' -and $Running -ne 'shared'){
Start-sleep -s 60
new-item "$env:APPDATA\microsoft\Signatures\$SignatureNames.adcheck.txt" | Out-Null
If ($GetName -ne $ADFullname)
{$msgBoxInputName = [System.Windows.MessageBox]::Show("Your name is different than in your signature`nSignature: $GetName`nSystem: $ADFullname`nDo you want to change this?","Signature","YesNoCancel","Warning")}
IF ($GetDepartment -ne $ADDepartment)
{$msgBoxInputDepartment = [System.Windows.MessageBox]::Show("Your department is different than in your signature`nSignature: $GetDepartment`nSystem: $ADDepartment`nDo you want to change this?","Signature","YesNoCancel","Warning")}
If ($Getfunction -ne $ADTitle)
{$msgBoxInputTitle = [System.Windows.MessageBox]::Show("Your title is different than in your signature`nSignature: $Getfunction`nSystem: $ADTitle`nDo you want to change this?","Signature","YesNoCancel","Warning")}
If ($GetEmail -ne $ADemail)
{$msgBoxInputemail = [System.Windows.MessageBox]::Show("Your email is different than in your signature`nSignature: $GetEmail`nSystem: $ADemail`nDo you want to change this?","Signature","YesNoCancel","Warning")}
If ($GetPhone -ne $AdPhone2)
{$msgBoxInputphone = [System.Windows.MessageBox]::Show("Your phonenumber is different than in your signature`nSignature: $GetPhone`nSystem: $AdPhone2`nDo you want to change this?","Signature","YesNoCancel","Warning")}
If ($GetMobile -ne " "){ If ($GetMobile -ne $ADMobile2)
{$msgBoxInputmobilephone = [System.Windows.MessageBox]::Show("Your mobile is different than in your signature`nSignature: $GetMobile`nSystem: $ADMobile2`nDo you want to change this?","Signature","YesNoCancel","Warning")}}
If (($GetName -eq $ADFullname -and $GetDepartment -eq $ADDepartment -and $Getfunction -eq $ADTitle -and $GetEmail -eq $ADemail -and $GetPhone -eq $AdPhone2) -and ($GetMobile -eq " " -or $GetMobile -eq $ADMobile2))
{
Exit}
If ($msgBoxInputName -eq $NULL -and $msgBoxInputDepartment -eq $NULL -and $msgBoxInputTitle -eq $NULL -and $msgBoxInputemail -eq $NULL -and $msgBoxInputphone -eq $NULL -and $msgBoxInputmobilephone -eq $NULL)
{
Exit}
## First last name check
switch ($msgBoxInputName) { 'Yes' { # Its using AD info
} 'No' { #Using Old name in new Signature
$ADFullname = $GetName
} 'Cancel' {
exit }
}
## Department Check
switch ($msgBoxInputDepartment) { 'Yes' { # Its using AD info
} 'No' { #Using Old name in new Signature
$ADDepartment = $GetDepartment
} 'Cancel' {
exit }
}
## Function / Title Check
switch ($msgBoxInputTitle) { 'Yes' { # Its using AD info
} 'No' { #Using Old name in new Signature
$ADTitle = $Getfunction
} 'Cancel' {
exit }
}
#Email Check
switch ($msgBoxInputemail) { 'Yes' { # Its using AD info
} 'No' { #Using Old name in new Signature
$ADemail = $GetEmail
} 'Cancel' {
exit }
}
#phone
switch ($msgBoxInputphone) { 'Yes' { # Its using AD info
} 'No' { #Using Old name in new Signature
$AdPhone2 = $GetPhone
} 'Cancel' {
exit }
}
# Mobile Check
switch ($msgBoxInputmobilephone) { 'Yes' { # Its using AD info
} 'No' { #Using Old name in new Signature
$ADMobile2 = $GetMobile
} 'Cancel' {
exit }
}
If (($msgBoxInputName -eq $NULL -or $msgBoxInputName -eq 'No') -and ($msgBoxInputDepartment -eq $NULL -or $msgBoxInputDepartment -eq 'No') -and ($msgBoxInputTitle -eq $NULL -or $msgBoxInputTitle -eq 'No') -and ($msgBoxInputemail -eq $NULL -or $msgBoxInputemail -eq 'No') -and ($msgBoxInputphone -eq $NULL -or $msgBoxInputphone -eq 'No') -and ($msgBoxInputmobilephone -eq $NULL -or $msgBoxInputmobilephone -eq 'No'))
{
Write-host exit 343
Exit}
If ($Werkzaamheden -ne $NULL){
$DagenWerkzaam2 = $Werkzaamheden
$DagenWerkzaam = @"
<br>
<span style='font-family:"Calibri Light";font-size:7.5pt;color:black'> $Werkzaamheden
"@
}}}
### Removing some old settings (Default signature)
$15New = Test-Path "HKCU:\Software\Microsoft\Office\15.0\Common\MailSettings"
$15rep = Test-Path "HKCU:\Software\Microsoft\Office\15.0\Common\MailSettings"
$16New = Test-Path "HKCU:\Software\Microsoft\Office\16.0\Common\MailSettings"
$16rep = Test-Path "HKCU:\Software\Microsoft\Office\16.0\Common\MailSettings"
If ($15New -eq "$true"){Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Office\15.0\Common\MailSettings" -Name "NewSignature" -ErrorAction SilentlyContinue | out-null}
If ($15rep -eq "$true"){Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Office\15.0\Common\MailSettings" -Name "ReplySignature" -ErrorAction SilentlyContinue | out-null}
If ($16New -eq "$true"){Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Office\16.0\Common\MailSettings" -Name "NewSignature" -ErrorAction SilentlyContinue | out-null}
If ($16rep -eq "$true"){Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Office\16.0\Common\MailSettings" -Name "ReplySignature" -ErrorAction SilentlyContinue | out-null}
$PostboxSplit = $ADBox -split ','
$PO = $PostboxSplit[0]
$POpostcode = $PostboxSplit[1]
If ($Running -eq "Shared")
{
######################################################################################
### START GUI ###
#######################################
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$form = New-Object System.Windows.Forms.Form
$form.Text = 'Email signature'
$form.Size = New-Object System.Drawing.Size(400,600)
$form.StartPosition = 'CenterScreen'
$okButton = New-Object System.Windows.Forms.Button
$okButton.Location = New-Object System.Drawing.Point(75,500)
$okButton.Size = New-Object System.Drawing.Size(75,23)
$okButton.Text = 'OK'
$okButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
$form.AcceptButton = $okButton
$form.Controls.Add($okButton)
$cancelButton = New-Object System.Windows.Forms.Button
$cancelButton.Location = New-Object System.Drawing.Point(150,500)
$cancelButton.Size = New-Object System.Drawing.Size(75,23)
$cancelButton.Text = 'Cancel'
$cancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
$form.CancelButton = $cancelButton
$form.Controls.Add($cancelButton)
$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(10,20)
$label.Size = New-Object System.Drawing.Size(280,20)
$label.Text = 'Set Signature Name'
$form.Controls.Add($label)
$textBox = New-Object System.Windows.Forms.TextBox
$textBox.Location = New-Object System.Drawing.Point(10,40)
$textBox.Size = New-Object System.Drawing.Size(260,20)
$textBox.Text = "Shared mailbox Name"
$form.Controls.Add($textBox)
$label2 = New-Object System.Windows.Forms.Label
$label2.Location = New-Object System.Drawing.Point(10,70)
$label2.Size = New-Object System.Drawing.Size(280,20)
$label2.Text = 'Set fist name last name field'
$form.Controls.Add($label2)
$textBox2 = New-Object System.Windows.Forms.TextBox
$textBox2.Location = New-Object System.Drawing.Point(10,90)
$textBox2.Size = New-Object System.Drawing.Size(260,20)
$textBox2.Text = $ADFullname
$form.Controls.Add($textBox2)
$label3 = New-Object System.Windows.Forms.Label
$label3.Location = New-Object System.Drawing.Point(10,120)
$label3.Size = New-Object System.Drawing.Size(280,20)
$label3.Text = 'Set Department - Make blank for no department.'
$form.Controls.Add($label3)
$textBox3 = New-Object System.Windows.Forms.TextBox
$textBox3.Location = New-Object System.Drawing.Point(10,140)
$textBox3.Size = New-Object System.Drawing.Size(260,20)
$textBox3.Text = $ADDepartment
$form.Controls.Add($textBox3)
$label4 = New-Object System.Windows.Forms.Label
$label4.Location = New-Object System.Drawing.Point(10,170)
$label4.Size = New-Object System.Drawing.Size(280,20)
$label4.Text = 'Set function - Make blank for no function.'
$form.Controls.Add($label4)
$textBox4 = New-Object System.Windows.Forms.TextBox
$textBox4.Location = New-Object System.Drawing.Point(10,190)
$textBox4.Size = New-Object System.Drawing.Size(260,20)
$textBox4.Text = $ADTitle
$form.Controls.Add($textBox4)
$label5 = New-Object System.Windows.Forms.Label
$label5.Location = New-Object System.Drawing.Point(10,220)
$label5.Size = New-Object System.Drawing.Size(280,20)
$label5.Text = "Set email address. Can't be blank"
$form.Controls.Add($label5)
$textBox5 = New-Object System.Windows.Forms.TextBox
$textBox5.Location = New-Object System.Drawing.Point(10,240)
$textBox5.Size = New-Object System.Drawing.Size(260,20)
$textBox5.Text = $ADemail
$form.Controls.Add($textBox5)
$label6 = New-Object System.Windows.Forms.Label
$label6.Location = New-Object System.Drawing.Point(10,270)
$label6.Size = New-Object System.Drawing.Size(280,20)
$label6.Text = "Set phonenumber. Can't be blank "
$form.Controls.Add($label6)
$textBox6 = New-Object System.Windows.Forms.TextBox
$textBox6.Location = New-Object System.Drawing.Point(10,290)
$textBox6.Size = New-Object System.Drawing.Size(260,20)
$textBox6.Text = $DefaultPhone
$form.Controls.Add($textBox6)
$form.Topmost = $true
$form.Add_Shown({$textBox.Select()})
$result = $form.ShowDialog()
if ($result -eq "Cancel")
{
exit
}
if ($result -eq [System.Windows.Forms.DialogResult]::OK)
{
$SharedSignatureName = $textBox.Text
$ADFullname = $textBox2.Text
$ADDepartment = $textBox3.Text
$ADTitle = $textBox4.Text
$ADemail = $textBox5.Text
$AdPhone = $textBox6.Text
$ADMobile = $NULL
$ADMobileNumber = $NULL
}
If ($SharedSignatureName -eq "")
{ EXIT }
If ($ADTitle -eq "") {$ADTitle = "<br>"}
}
If ($Embedd -eq "Yes")
{
$logo2 = $Logo.split("/")[-1]
Invoke-WebRequest $Logo -OutFile "$env:APPDATA\microsoft\Signatures\$logo2"
$Logo = "$env:APPDATA\microsoft\Signatures\$logo2"
$FacebookLogo2 = $FacebookLogo.split("/")[-1]
Invoke-WebRequest $FacebookLogo -OutFile "$env:APPDATA\microsoft\Signatures\$FacebookLogo2"
$FacebookLogo = "$env:APPDATA\microsoft\Signatures\$FacebookLogo2"
$InstagramLogo2 = $InstagramLogo.split("/")[-1]
Invoke-WebRequest $InstagramLogo -OutFile "$env:APPDATA\microsoft\Signatures\$InstagramLogo2"
$InstagramLogo = "$env:APPDATA\microsoft\Signatures\$InstagramLogo2"
$LinkedinLogo2 = $LinkedinLogo.split("/")[-1]
Invoke-WebRequest $LinkedinLogo -OutFile "$env:APPDATA\microsoft\Signatures\$LinkedinLogo2"
$LinkedinLogo = "$env:APPDATA\microsoft\Signatures\$LinkedinLogo2"
$TwitterLogo2 = $TwitterLogo.split("/")[-1]
Invoke-WebRequest $TwitterLogo -OutFile "$env:APPDATA\microsoft\Signatures\$TwitterLogo2"
$TwitterLogo = "$env:APPDATA\microsoft\Signatures\$TwitterLogo2"
$YoutubeLogo2 = $YoutubeLogo.split("/")[-1]
Invoke-WebRequest $YoutubeLogo -OutFile "$env:APPDATA\microsoft\Signatures\$YoutubeLogo2"
$YoutubeLogo = "$env:APPDATA\microsoft\Signatures\$YoutubeLogo2"
$16sendpic = Test-Path "HKCU:\Software\Microsoft\Office\16.0\Outlook\Options"
$16sendpicm = Test-Path "HKCU:\Software\Microsoft\Office\16.0\Outlook\Options\Mail"
$15sendpic = Test-Path "HKCU:\Software\Microsoft\Office\15.0\Outlook\Options"
$15sendpicm = Test-Path "HKCU:\Software\Microsoft\Office\15.0\Outlook\Options\Mail"
If ($16sendpic -eq "$true"){
If (! (Test-Path "HKCU:\Software\Microsoft\Office\16.0\Outlook\Options\Mail")){new-ItemProperty -Path HKCU:\Software\Microsoft\Office\16.0\Outlook\Options -Name Mail | out-null}
new-ItemProperty -Path HKCU:\Software\Microsoft\Office\16.0\Outlook\Options\Mail -name 'Send Pictures With Document' -Value 1 -PropertyType DWORD -Force | out-null}
if ($15sendpic -eq "$true"){
If (! (Test-Path "HKCU:\Software\Microsoft\Office\15.0\Outlook\Options\Mail")){new-ItemProperty -Path HKCU:\Software\Microsoft\Office\15.0\Outlook\Options -Name Mail | out-null}
new-ItemProperty -Path HKCU:\Software\Microsoft\Office\15.0\Outlook\Options\Mail -name 'Send Pictures With Document' -Value 1 -PropertyType DWORD -Force | out-null}
}
If ($Embedd -eq "No")
{
$16sendpic = Test-Path "HKCU:\Software\Microsoft\Office\16.0\Outlook\Options"
$16sendpicm = Test-Path "HKCU:\Software\Microsoft\Office\16.0\Outlook\Options\Mail"
$15sendpic = Test-Path "HKCU:\Software\Microsoft\Office\15.0\Outlook\Options"
$15sendpicm = Test-Path "HKCU:\Software\Microsoft\Office\15.0\Outlook\Options\Mail"
If ($16sendpic -eq "$true"){
If (! (Test-Path "HKCU:\Software\Microsoft\Office\16.0\Outlook\Options\Mail"))
{New-Item -path 'HKCU:\Software\Microsoft\Office\16.0\Outlook\Options' -Name Mail | out-null}
new-ItemProperty -Path HKCU:\Software\Microsoft\Office\16.0\Outlook\Options\Mail -name 'Send Pictures With Document' -Value 0 -PropertyType DWORD -Force | out-null}
If ($15sendpic -eq "$true"){
If (! (Test-Path "HKCU:\Software\Microsoft\Office\15.0\Outlook\Options\Mail"))
{New-Item -path 'HKCU:\Software\Microsoft\Office\15.0\Outlook\Options' -Name Mail | out-null}
new-ItemProperty -Path HKCU:\Software\Microsoft\Office\15.0\Outlook\Options\Mail -name 'Send Pictures With Document' -Value 0 -PropertyType DWORD -Force | out-null}
}
###############################################################
## Create HTML for the logo's
$count =3
If ($FacebookURL -ne "")
{$count ++
If ($FacebookTrack -ne "")
{
$FacebookTrackhtml = 'target="_blank" data-saferedirecturl="$FacebookTrack"'
}
If ($FacebookTrack -eq "")
{$FacebookTrackhtml = ""
}
$FacebookHTML=@"
<td nowrap valign=top style="padding: 0px 5px 0px 0px; height: 40px; line-height: 13px; overflow: hidden; font-size: 10px; vertical-align: middle;">
<a href="$FacebookURL" $FacebookTrackhtml><img width="22" height="22" class="CToWUd" style="margin: 0px; width: 22px; height: 22px;" alt="Image" src="$FacebookLogo"></a></span>
</td>
"@
}
If ($InstagramURL -ne "")
{
$count ++
If ($InstagramTrack -ne "")
{$InstagramTrackhtml = 'target="_blank" data-saferedirecturl="$InstagramTrack"'}
If ($InstagramTrack -eq "")
{$InstagramTrackhtml = ""}
$InstagramHTML =@"
<td nowrap valign=top style="padding: 0px 5px 0px 0px; height: 40px; line-height: 13px; overflow: hidden; font-size: 10px; vertical-align: middle;">
<a href="$InstagramURL" $InstagramTrackhtml><img width="22" height="22" class="CToWUd" style="margin: 0px; width: 22px; height: 22px;" alt="Image" src="$InstagramLogo" ></a></span>
</td>
"@
}
If ($LinkedinURL -ne "")
{
$count ++
If ($LinkedinTrack -ne "")
{$LinkedinTrackhtml = 'target="_blank" data-saferedirecturl="$LinkedinTrack"'}
If ($LinkedinTrack -eq "")
{$LinkedinTrackhtml = ""}
$LinkedinHTML =@"
<td nowrap valign=top style="padding: 0px 5px 0px 0px; height: 40px; line-height: 13px; overflow: hidden; font-size: 10px; vertical-align: middle;">
<a href="$LinkedinURL" $LinkedinTrackhtml><img width="22" height="22" class="CToWUd" style="margin: 0px; width: 22px; height: 22px;" alt="Image" src="$LinkedinLogo" ></a></span>
</td>
"@
}
If ($TwitterURL -ne "")
{
$count ++
If ($TwitterTrack -ne "")
{$TwitterTrackhtml = 'target="_blank" data-saferedirecturl="$TwitterTrack"'}
If ($TwitterTrack -eq "")
{$TwitterTrackhtml = ""}
$TwitterHTML = @"
<td nowrap valign=top style="padding: 0px 5px 0px 0px; height: 40px; line-height: 13px; overflow: hidden; font-size: 10px; vertical-align: middle;">
<a href="$TwitterURL" $TwitterTrackhtml><img width="22" height="22" class="CToWUd" style="margin: 0px; width: 22px; height: 22px;" alt="Image" src="$TwitterLogo" ></a></span>
</td>
"@
}
If ($YoutubeURL -ne "")
{
$count ++
If ($YoutubeTrack -ne "")
{$YoutubeTrackhtml = 'target="_blank" data-saferedirecturl="$YoutubeTrack"'}
If ($YoutubeTrack -eq "")
{$YoutubeTrackhtml = ""}
$YoutubeHTML = @"
<td nowrap valign=top style="padding: 0px 5px 0px 0px; height: 40px; line-height: 13px; overflow: hidden; font-size: 10px; vertical-align: middle;">
<a href="$YoutubeURL" $YoutubeTrackhtml><img width="22" height="22" class="CToWUd" style="margin: 0px; width: 22px; height: 22px;" alt="Image" src="$YoutubeLogo" ></a></span>
</td>
"@
}
If ($FacebookURL -ne "" -or $InstagramURL -ne "" -or $LinkedinURL -ne ""-or $TwitterURL -ne "" -or $YoutubeURL -ne "")
{$SocialLogos = @"
<td td nowrap valign=top style="padding: 0px 0px 0px 10px; height: 40px; line-height: 13px; border-left-color: gray; border-left-width: 1px; border-left-style: solid;">
</td>
$FacebookHTML
$InstagramHTML
$LinkedinHTML
$TwitterHTML
$YoutubeHTML
"@
}
## Create Menu
#############################
If ($Running -eq "Test")
{
Write-host "no input"
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$Starmenu = New-Object System.Windows.Forms.Form
$Starmenu.Text = 'Setup Email Signature'
$Starmenu.Size = New-Object System.Drawing.Size(400,300)
$Starmenu.StartPosition = 'CenterScreen'
$cancelButton = New-Object System.Windows.Forms.Button
$cancelButton.Location = New-Object System.Drawing.Point(150,200)
$cancelButton.Size = New-Object System.Drawing.Size(75,23)
$cancelButton.Text = 'Cancel'
$cancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
$Starmenu.CancelButton = $cancelButton
$Starmenu.Controls.Add($cancelButton)
############### Buttons
$AddButton = New-Object System.Windows.Forms.Button
$AddButton.Location = New-Object System.Drawing.Point(10,60)
$AddButton.Size = New-Object System.Drawing.Size(300,23)
$AddButton.Text = 'Add Shared mailbox signature'
$Starmenu.Controls.Add($AddButton)
$AddButton.Add_Click($Button_Click)
$Starmenu.Topmost = $true
$Starmenuresult = $Starmenu.ShowDialog()
Write-Host $Button_Click
Write-Host $Starmenuresult
if ($Starmenuresult -eq "Cancel")
{
exit
}
}
###############################################################
## Create Checkbox workingdays
#############################
If ($Running -eq "aanwezig")
{
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$form = New-Object System.Windows.Forms.Form
$form.Text = 'Email signature'
$form.Size = New-Object System.Drawing.Size(500,300)
$form.StartPosition = 'CenterScreen'
$okButton = New-Object System.Windows.Forms.Button
$okButton.Location = New-Object System.Drawing.Point(175,230)
$okButton.Size = New-Object System.Drawing.Size(75,23)
$okButton.Text = 'OK'
$okButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
$form.AcceptButton = $okButton
$form.Controls.Add($okButton)
$cancelButton = New-Object System.Windows.Forms.Button
$cancelButton.Location = New-Object System.Drawing.Point(250,230)
$cancelButton.Size = New-Object System.Drawing.Size(75,23)
$cancelButton.Text = 'Cancel'
$cancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
$form.CancelButton = $cancelButton
$form.Controls.Add($cancelButton)
# Create a group that will contain your radio buttons
$languageGroupBox = New-Object System.Windows.Forms.GroupBox
$languageGroupBox.Location = '10,30'
$languageGroupBox.size = '250,40'
$languageGroupBox.text = "Selecteer Taal/Select output language"
# Create the collection of radio buttons
$languageRadioButton1 = New-Object System.Windows.Forms.RadioButton
$languageRadioButton1.Location = '10,20'
$languageRadioButton1.size = '80,20'
$languageRadioButton1.Checked = $true
$languageRadioButton1.Text = "Nederlands"
$languageRadioButton2 = New-Object System.Windows.Forms.RadioButton
$languageRadioButton2.Location = '100,20'
$languageRadioButton2.size = '80,20'
$languageRadioButton2.Checked = $false
$languageRadioButton2.Text = "English"
# Add all the GroupBox controls on one line
$languageGroupBox.Controls.AddRange(@($languageRadioButton1,$languageRadioButton2))
# Add all the Form controls on one line
$form.Controls.AddRange(@($languageGroupBox))
$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(10,80)
$label.Size = New-Object System.Drawing.Size(280,20)
$label.Text = 'Selecteer je werk dagen / Select your working days'
$form.Controls.Add($label)
$label2 = New-Object System.Windows.Forms.Label
$label2.Location = New-Object System.Drawing.Point(160,100)
$label2.Size = New-Object System.Drawing.Size(350,20)
$label2.Text = 'Hele dag / Full Day | Ochtend / Morning | Middag / Afternoon'
$form.Controls.Add($label2)
$MondayBox = New-Object System.Windows.Forms.Checkbox
$MondayBox.Location = New-Object System.Drawing.Point(10,120)
$MondayBox.Size = New-Object System.Drawing.Size(150,20)
$MondayBox.Text = "maandag / Monday"
$form.Controls.Add($MondayBox)
######################
# Create a group that will contain your radio buttons
$mondayGroupBox = New-Object System.Windows.Forms.GroupBox
$mondayGroupBox.Location = '200,120'
$mondayGroupBox.size = '250,20'
# Create the collection of radio buttons
$mondayRadioButton1 = New-Object System.Windows.Forms.RadioButton
$mondayRadioButton1.Location = '1,1'
$mondayRadioButton1.size = '20,20'
$mondayRadioButton1.Checked = $true
$mondayRadioButton2 = New-Object System.Windows.Forms.RadioButton
$mondayRadioButton2.Location = '110,1'
$mondayRadioButton2.size = '20,20'
$mondayRadioButton2.Checked = $false
$mondayRadioButton3 = New-Object System.Windows.Forms.RadioButton
$mondayRadioButton3.Location = '200,1'
$mondayRadioButton3.size = '20,20'
$mondayRadioButton3.Checked = $false
# Add all the GroupBox controls on one line
$mondayGroupBox.Controls.AddRange(@($mondayRadioButton1,$mondayRadioButton2,$mondayRadioButton3))
# Add all the Form controls on one line
$form.Controls.AddRange(@($mondayGroupBox))
$TuesdayBox = New-Object System.Windows.Forms.Checkbox
$TuesdayBox.Location = New-Object System.Drawing.Point(10,140)
$TuesdayBox.Size = New-Object System.Drawing.Size(150,20)
$TuesdayBox.Text = "dinsdag / Tuesday"
$form.Controls.Add($TuesdayBox)
######################
# Create a group that will contain your radio buttons
$TuesdayGroupBox = New-Object System.Windows.Forms.GroupBox
$TuesdayGroupBox.Location = '200,140'
$TuesdayGroupBox.size = '250,20'
# Create the collection of radio buttons
$TuesdayRadioButton1 = New-Object System.Windows.Forms.RadioButton
$TuesdayRadioButton1.Location = '1,1'
$TuesdayRadioButton1.size = '20,20'
$TuesdayRadioButton1.Checked = $true
$TuesdayRadioButton2 = New-Object System.Windows.Forms.RadioButton
$TuesdayRadioButton2.Location = '110,1'
$TuesdayRadioButton2.size = '20,20'
$TuesdayRadioButton2.Checked = $false
$TuesdayRadioButton3 = New-Object System.Windows.Forms.RadioButton
$TuesdayRadioButton3.Location = '200,1'
$TuesdayRadioButton3.size = '20,20'
$TuesdayRadioButton3.Checked = $false
# Add all the GroupBox controls on one line
$TuesdayGroupBox.Controls.AddRange(@($TuesdayRadioButton1,$TuesdayRadioButton2,$TuesdayRadioButton3))
# Add all the Form controls on one line
$form.Controls.AddRange(@($TuesdayGroupBox))
$WednesdayBox = New-Object System.Windows.Forms.Checkbox
$WednesdayBox.Location = New-Object System.Drawing.Point(10,160)
$WednesdayBox.Size = New-Object System.Drawing.Size(160,20)
$WednesdayBox.Text = "woensdag / Wednesday"
$form.Controls.Add($WednesdayBox)
######################
# Create a group that will contain your radio buttons
$WednesdayGroupBox = New-Object System.Windows.Forms.GroupBox
$WednesdayGroupBox.Location = '200,160'
$WednesdayGroupBox.size = '250,20'
# Create the collection of radio buttons
$WednesdayRadioButton1 = New-Object System.Windows.Forms.RadioButton
$WednesdayRadioButton1.Location = '1,1'
$WednesdayRadioButton1.size = '20,20'
$WednesdayRadioButton1.Checked = $true
$WednesdayRadioButton2 = New-Object System.Windows.Forms.RadioButton
$WednesdayRadioButton2.Location = '110,1'
$WednesdayRadioButton2.size = '20,20'
$WednesdayRadioButton2.Checked = $false
$WednesdayRadioButton3 = New-Object System.Windows.Forms.RadioButton
$WednesdayRadioButton3.Location = '200,1'
$WednesdayRadioButton3.size = '20,20'
$WednesdayRadioButton3.Checked = $false
# Add all the GroupBox controls on one line
$WednesdayGroupBox.Controls.AddRange(@($WednesdayRadioButton1,$WednesdayRadioButton2,$WednesdayRadioButton3))
# Add all the Form controls on one line
$form.Controls.AddRange(@($WednesdayGroupBox))
$ThursdayBox = New-Object System.Windows.Forms.Checkbox
$ThursdayBox.Location = New-Object System.Drawing.Point(10,180)
$ThursdayBox.Size = New-Object System.Drawing.Size(150,20)
$ThursdayBox.Text = "donderdag / Thursday"
$form.Controls.Add($ThursdayBox)
######################
# Create a group that will contain your radio buttons
$ThursdayGroupBox = New-Object System.Windows.Forms.GroupBox
$ThursdayGroupBox.Location = '200,180'
$ThursdayGroupBox.size = '250,20'
# Create the collection of radio buttons
$ThursdayRadioButton1 = New-Object System.Windows.Forms.RadioButton
$ThursdayRadioButton1.Location = '1,1'
$ThursdayRadioButton1.size = '20,20'
$ThursdayRadioButton1.Checked = $true
$ThursdayRadioButton2 = New-Object System.Windows.Forms.RadioButton
$ThursdayRadioButton2.Location = '110,1'
$ThursdayRadioButton2.size = '20,20'
$ThursdayRadioButton2.Checked = $false
$ThursdayRadioButton3 = New-Object System.Windows.Forms.RadioButton
$ThursdayRadioButton3.Location = '200,1'
$ThursdayRadioButton3.size = '20,20'
$ThursdayRadioButton3.Checked = $false
# Add all the GroupBox controls on one line
$ThursdayGroupBox.Controls.AddRange(@($ThursdayRadioButton1,$ThursdayRadioButton2,$ThursdayRadioButton3))
# Add all the Form controls on one line
$form.Controls.AddRange(@($ThursdayGroupBox))
$FridayBox = New-Object System.Windows.Forms.Checkbox
$FridayBox.Location = New-Object System.Drawing.Point(10,200)
$FridayBox.Size = New-Object System.Drawing.Size(150,20)
$FridayBox.Text = "vrijdag / Friday"
$form.Controls.Add($Fridaybox)
######################
# Create a group that will contain your radio buttons
$FridayBoxGroupBox = New-Object System.Windows.Forms.GroupBox
$FridayBoxGroupBox.Location = '200,200'
$FridayBoxGroupBox.size = '250,20'
# Create the collection of radio buttons
$FridayRadioButton1 = New-Object System.Windows.Forms.RadioButton
$FridayRadioButton1.Location = '1,1'
$FridayRadioButton1.size = '20,20'
$FridayRadioButton1.Checked = $true
$FridayRadioButton2 = New-Object System.Windows.Forms.RadioButton
$FridayRadioButton2.Location = '110,1'
$FridayRadioButton2.size = '20,20'
$FridayRadioButton2.Checked = $false
$FridayRadioButton3 = New-Object System.Windows.Forms.RadioButton
$FridayRadioButton3.Location = '200,1'
$FridayRadioButton3.size = '20,20'
$FridayRadioButton3.Checked = $false
# Add all the GroupBox controls on one line
$FridayBoxGroupBox.Controls.AddRange(@($FridayRadioButton1,$FridayRadioButton2,$FridayRadioButton3))
# Add all the Form controls on one line
$form.Controls.AddRange(@($FridayBoxGroupBox))
$form.Topmost = $true
#$form.Add_Shown({$textBox.Select()})
$result = $form.ShowDialog()
if ($result -eq [System.Windows.Forms.DialogResult]::OK)
{
If ($languageRadioButton1.Checked){$Language = "Werkzaam op"}
If ($languageRadioButton2.Checked){$Language = "Working on"}
If ($languageRadioButton1.Checked -and $MondayBox.Checked -and $mondayRadioButton1.Checked) {$Monday = "maandag"}
If ($languageRadioButton1.Checked -and $MondayBox.Checked -and $mondayRadioButton2.Checked) {$Monday = "maandag ochtend"}
If ($languageRadioButton1.Checked -and $MondayBox.Checked -and $mondayRadioButton3.Checked) {$Monday = "maandag middag"}
If ($languageRadioButton2.Checked -and $MondayBox.Checked -and $mondayRadioButton1.Checked) {$Monday = "Monday"}
If ($languageRadioButton2.Checked -and $MondayBox.Checked -and $mondayRadioButton2.Checked) {$Monday = "Monday morning"}
If ($languageRadioButton2.Checked -and $MondayBox.Checked -and $mondayRadioButton3.Checked) {$Monday = "Monday afternoon"}
If ($languageRadioButton1.Checked -and $TuesdayBox.Checked -and $TuesdayRadioButton1.Checked) {$Tuesday = "dinsdag"}
If ($languageRadioButton1.Checked -and $TuesdayBox.Checked -and $TuesdayRadioButton2.Checked) {$Tuesday = "dinsdag ochtend"}
If ($languageRadioButton1.Checked -and $TuesdayBox.Checked -and $TuesdayRadioButton2.Checked) {$Tuesday = "dinsdag middag"}
If ($languageRadioButton2.Checked -and $TuesdayBox.Checked -and $TuesdayRadioButton1.Checked) {$Tuesday = "Tuesday"}
If ($languageRadioButton2.Checked -and $TuesdayBox.Checked -and $TuesdayRadioButton2.Checked) {$Tuesday = "Tuesday morning"}
If ($languageRadioButton2.Checked -and $TuesdayBox.Checked -and $TuesdayRadioButton2.Checked) {$Tuesday = "Tuesday afternoon"}
If ($languageRadioButton1.Checked -and $WednesdayBox.Checked -and $WednesdayRadioButton1.Checked) {$Wednesday = "woensdag"}
If ($languageRadioButton1.Checked -and $WednesdayBox.Checked -and $WednesdayRadioButton2.Checked) {$Wednesday = "woensdag ochtend"}
If ($languageRadioButton1.Checked -and $WednesdayBox.Checked -and $WednesdayRadioButton3.Checked) {$Wednesday = "woensdag middag"}
If ($languageRadioButton2.Checked -and $WednesdayBox.Checked -and $WednesdayRadioButton1.Checked) {$Wednesday = "Wednesday"}
If ($languageRadioButton2.Checked -and $WednesdayBox.Checked -and $WednesdayRadioButton2.Checked) {$Wednesday = "Wednesday morning"}
If ($languageRadioButton2.Checked -and $WednesdayBox.Checked -and $WednesdayRadioButton3.Checked) {$Wednesday = "Wednesday afternoon"}
If ($languageRadioButton1.Checked -and $ThursdayBox.Checked -and $ThursdayRadioButton1.Checked) {$Thursday = "donderdag"}
If ($languageRadioButton1.Checked -and $ThursdayBox.Checked -and $ThursdayRadioButton2.Checked) {$Thursday = "donderdag ochtend"}
If ($languageRadioButton1.Checked -and $ThursdayBox.Checked -and $ThursdayRadioButton3.Checked) {$Thursday = "donderdag middag"}
If ($languageRadioButton2.Checked -and $ThursdayBox.Checked -and $ThursdayRadioButton1.Checked) {$Thursday = "Thursday"}
If ($languageRadioButton2.Checked -and $ThursdayBox.Checked -and $ThursdayRadioButton2.Checked) {$Thursday = "Thursday morning"}
If ($languageRadioButton2.Checked -and $ThursdayBox.Checked -and $ThursdayRadioButton3.Checked) {$Thursday = "Thursday afternoon"}
If ($languageRadioButton1.Checked -and $Fridaybox.Checked -and $FridayRadioButton1.Checked) {$Friday = "vrijdag"}
If ($languageRadioButton1.Checked -and $Fridaybox.Checked -and $FridayRadioButton2.Checked) {$Friday = "vrijdag ochtend"}
If ($languageRadioButton1.Checked -and $Fridaybox.Checked -and $FridayRadioButton3.Checked) {$Friday = "vrijdag middag"}
If ($languageRadioButton2.Checked -and $Fridaybox.Checked -and $FridayRadioButton1.Checked) {$Friday = "Friday "}
If ($languageRadioButton2.Checked -and $Fridaybox.Checked -and $FridayRadioButton2.Checked) {$Friday = "Friday morning"}
If ($languageRadioButton2.Checked -and $Fridaybox.Checked -and $FridayRadioButton3.Checked) {$Friday = "Friday afternoon"}
$komma = ", "
If (($MondayBox.Checked -eq $True) -and ($TuesdayBox.Checked -eq $True -or $WednesdayBox.Checked -eq $True -or $ThursdayBox.Checked -eq $True -or $Fridaybox.Checked -eq $True))
{$Monday = $Monday+$komma}
If (($TuesdayBox.Checked -eq $True) -and ($WednesdayBox.Checked -eq $True -or $ThursdayBox.Checked -eq $True -or $Fridaybox.Checked -eq $True))
{$Tuesday = $Tuesday+$komma}
If (($WednesdayBox.Checked -eq $True) -and ($ThursdayBox.Checked -eq $True -or $Fridaybox.Checked -eq $True))
{$Wednesday = $Wednesday+$komma}
If ($ThursdayBox.Checked -eq $True -and $Fridaybox.Checked -eq $True)
{$Thursday = $Thursday+$komma}
$DagenWerkzaam = @"
<br>
<span style='font-family:"Calibri Light";color:black'> $Language $Monday$Tuesday$Wednesday$Thursday$Friday
"@
$DagenWerkzaam2 = $Language +" "+ $Monday+$Tuesday+$Wednesday+$Thursday+$Friday
}
}
#### Check Adress
If ($Adress1 -eq "" -and $Adress2 -eq "" -and $Adress3 -eq "")
{
$Adress1 = $AdStreet
$Adress2 = "$AdZip $AdTown"
$Adress3 = $AdCountry
}
If ($ADMobile -notlike $null)
{
$ADWWW = @"
<span style='font-family:"Calibri"'>M </span><span style='font-family:"Calibri"'>$ADMobileNumber </span>
"@
}
else
{
$ADWWW = @"
<a href=$ADweb_address><span style=font-family:"Calibri">$ADweb_address </span></a>
"@
}
If ($ADBox -ne "")
{$count ++
$PostboxHTML=@"
<td td nowrap valign=top style="padding: 0px 10px 0px 10px;; height: 40px; line-height: 13px; border-left-color: gray; border-left-width: 1px; border-left-style: solid;">
<span style='font-family:"Calibri Light";font-size:7.5pt;color:black'>$PO </span>
<BR>
<span style='font-family:"Calibri Light";font-size:7.5pt;color:black'>$POpostcode $AdTown </span>
<BR>
<span style='font-family:"Calibri Light";font-size:7.5pt;color:black'>$AdCountry </span>
</td>
"@
}
#Create the signaturefile
$Html=@"
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
$Greetings
<BR>
<BR>
$Logo
$ADFullname
<BR>
$ADDepartment
<BR>
$ADTitle
$ADemail $AdPhone
<BR>
$ADWWW
$Adress1 $Adress2 $Adress3
$PostboxHTML
$SocialLogos
$DagenWerkzaam
</body>
</html>
"@
If ($SharedSignatureName -ne $null)
{$SignatureName = $SharedSignatureName }
If ($SharedSignatureName -eq $NULL)
{$SignatureName = $SignatureNames}
$Html | Out-File "$env:APPDATA\microsoft\Signatures\$SignatureName.htm" -Force
If ($Embedd -eq 'No')
{
###################
## Create RTF
#Creates RTF Signature
$wrd = new-object -com word.application
# Make Word Visible
$wrd.visible = $false
# Open a document
$fullPath = "$env:APPDATA\microsoft\Signatures\$SignatureName.htm"
$doc = $wrd.documents.open($fullpath)
# Save as rtf
$opt = 6
$name = "$env:APPDATA\microsoft\Signatures\$SignatureName.rtf"
$wrd.ActiveDocument.Saveas($name,$opt)
# Close word
$wrd.Quit()
}
#########################################
### Create TXT file
$stream = [System.IO.StreamWriter] "$env:APPDATA\microsoft\Signatures\$SignatureName.txt"
#$stream = [System.IO.StreamWriter] "$FolderLocation\\$strName.txt"
$stream.WriteLine("$Greetings")
$stream.WriteLine("$ADFullname")
$stream.WriteLine("$ADDepartment")
$stream.WriteLine("$ADTitle")
$stream.WriteLine(" ")
$stream.WriteLine("$ADemail")
$stream.WriteLine("T $AdPhone")
If ($ADMobile -ne ""){
$stream.WriteLine("M $ADMobileNumber")
}
If ($ADMobile -eq ""){
$stream.WriteLine("$ADweb_address")
}
$stream.WriteLine(" ")
$stream.WriteLine("$Adress1, $Adress2, $AdCountry")
If ($POpostcode -ne $NULL){
$stream.WriteLine("$PO, $POpostcode, $AdTown, $AdCountry")
}
$stream.WriteLine("$DagenWerkzaam2")
$stream.close()
If ($Running -ne "Shared")
{$SignatureName = $SignatureNames
### Set New email and reply
$MSWord = New-Object -com word.application
$EmailOptions = $MSWord.EmailOptions
$EmailSignature = $EmailOptions.EmailSignature
$EmailSignatureEntries = $EmailSignature.EmailSignatureEntries
$EmailSignature.NewMessageSignature = $SignatureName
$EmailSignature.ReplyMessageSignature = $SignatureName
$MSWord.Quit()
Set-ItemProperty -Path HKCU:\Software\Microsoft\Office\16.0\Common\General -name Signatures -Value Signatures | out-null
$OutlookProfilePath = "HKCU:\SOFTWARE\Microsoft\Office\16.0\Outlook\Profiles\Outlook\9375CFF0413111d3B88A00104B2A6676\00000002"
Get-Item -Path $OutlookProfilePath | New-Itemproperty -Name "New Signature" -value $SignatureName -Propertytype string -Force | out-null
Get-Item -Path $OutlookProfilePath | New-Itemproperty -Name "Reply-Forward Signature" -value $SignatureName -Propertytype string -Force | out-null
}
If (Test-path $env:APPDATA\microsoft\Signatures\$OldSignaturenametoremove.*){
Remove-Item $env:APPDATA\microsoft\Signatures\$OldSignaturenametoremove.* | out-null
}
}
Write-Host "Email signature is done"
}
Else {Write-host "Embedd value is incorrect configured"
}
############################################################################################################################################