Thank you.
When I do that replacement it crashes.
Secound problem is that when I want to setup that signature for new and reply in Outlook I do it over registry, but it doesn't accept that.
Here is complete code that creates signature copies to Signature map, creates registry keys but not working. You still need to click in Options to choose signature for new and reply.
# Gets the path to the user appdata folder
$AppData = (Get-Item env:appdata).value
# This is the default signature folder for Outlook
$localSignatureFolder = $AppData+'\Microsoft\Signatures'
# This is a shared folder on your network where the signature template should be
$templateFilePath = "\\BLED\Installer\signature"
$obavest = "To e-sporočilo (z vsemi prilogami) je namenjeno izključno izbranim prejemnikom. Če niste predvideni prejemnik in ste to e-sporočilo prejeli po pomoti, o tem nemudoma obvestite pošiljatelja ter izbrišite izvirno e-sporočilo in priloge brez podvajanja, distribucije ali prenosa vsebine katerikoli osebi ali organizaciji. Nepooblaščena uporaba, objava, shranjevanje in podvajanje vsebine e-sporočila je strogo prepovedano. Prenos e-sporočila ne zagotavlja, da so vsebovane informacije varne ali brez napak, saj so lahko elektronske informacije zastarele ali nepopolne, lahko so prestrežene, poškodovane, izgubljene ali vsebujejo viruse. Express One Si, d.o.o., zavrača kakršnokoli odgovornost za kakršnokoli škodo, povzročeno s prejemom in/ali uporabo tega e-sporočila kot tudi prilog, priloženih v tem e-sporočilu."
$name_addon = "je vpisano dne 1. 4. 2022 v sodni register Okrožnega sodišča v Ljubljani; ID za DDV: SI 30657008, matična številka: 9101691000."
$85disclamer = "This email (with any attachments) is intended for the attention of the addressee(s) only. If you are not the intended recipient, please inform the sender straight away before deleting the message without copying, distributing or disclosing its contents to any other person or organisation. Unauthorised use, disclosure, storage or copying is not permitted. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. Express One SI, d.o.o. therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission."
# Get the current logged in username
$userName = $env:username
# The following 5 lines will query AD and get an ADUser object with all information
$filter = "(&(objectCategory=User)(samAccountName=$userName))"
$searcher = New-Object System.DirectoryServices.DirectorySearcher
$searcher.Filter = $filter
$ADUserPath = $searcher.FindOne()
$ADUser = $ADUserPath.GetDirectoryEntry()
# Now extract all the necessary information for the signature
$name = $ADUser.DisplayName
$email = $ADUser.mail
$job = $ADUser.title
$address = $ADUser.streetAddress
$phone = $ADUser.mobile
$office = $ADUser.physicalDeliveryOfficeName
$FirmName = $ADUser.Company
$contry = $ADUser.co
$st0 = $ADUser.st
$PostalCode = $ADUser.postalCode
$Obavestilo = $obavest
$nameAddon = $name_addon
$77disclamer_eng = $85disclamer
$namePlaceHolder = "DISPLAY_NAME"
$emailPlaceHolder = "EMAIL"
$jobPlaceHolder = "JOB"
$addressPlaceHolder = "ADDRESS"
$phonePlaceHolder = "PHONE"
$FirmNamePlaceHolder = "FIRM_NAME"
$contryPlaceHolder = "CO23"
$st0PlaceHolder = "STATE"
$PostalCodePlaceHolder = "POSTAL"
$ObavestiloPlaceHolder = "OBAVESTILO"
$nameAddonPlaceHolder = "NAME_ADDON"
$77disclamer_engPlaceHolder = "WDISCLAMER"
$rawTemplate = get-content $templateFilePath"\signature_template.html"
$signature = $rawTemplate -replace $namePlaceHolder,$name
$rawTemplate = $signature
$signature = $rawTemplate -replace $emailPlaceHolder,$email
$rawTemplate = $signature
$signature = $rawTemplate -replace $phonePlaceHolder,$phone
$rawTemplate = $signature
$signature = $rawTemplate -replace $addressPlaceHolder, $address
$rawTemplate = $signature
$signature = $rawTemplate -replace $FirmNamePlaceHolder, $FirmName
$rawTemplate = $signature
$signature = $rawTemplate -replace $contryPlaceHolder, $contry
$rawTemplate = $signature
$signature = $rawTemplate -replace $st0PlaceHolder, $st0
$rawTemplate = $signature
$signature = $rawTemplate -replace $PostalCodePlaceHolder, $PostalCode
$rawTemplate = $signature
$signature = $rawTemplate -replace $ObavestiloPlaceHolder, $obavest
$rawTemplate = $signature
$signature = $rawTemplate -replace $nameAddonPlaceHolder, $name_addon
$rawTemplate = $signature
$signature = $rawTemplate -replace $jobPlaceHolder, $job
$rawTemplate = $signature
$signature = $rawTemplate -replace $77disclamer_engPlaceHolder, $77disclamer_eng
$rawTemplate = $signature
# Save it as <username>.htm
$fileName = $localSignatureFolder + "\" + $userName + ".htm"
# Create rich text file
# Gets the last update time of the template.
if(test-path $templateFilePath){
$templateLastModifiedDate = [datetime](Get-ItemProperty -Path $templateFilePath -Name LastWriteTime).lastwritetime
}
# Checks if there is a signature and its last update time
if(test-path $fileName){
$signatureLastModifiedDate = [datetime](Get-ItemProperty -Path $fileName -Name LastWriteTime).lastwritetime
if((get-date $templateLastModifiedDate) -gt (get-date $signatureLastModifiedDate)){
$signature > $fileName
}
}else{
$signature > $fileName
}
#this section enables signature to Outlook to be placed in new and reply
# Setting the regkeys for Outlook 2016
if (test-path "HKCU:\\Software\\Microsoft\\Office\\16.0\\Common\\General")
{
get-item -path HKCU:\\Software\\Microsoft\\Office\\16.0\\Common\\General | new-Itemproperty -name Signatures -value signatures -propertytype string -force
get-item -path HKCU:\\Software\\Microsoft\\Office\\16.0\\Common\\MailSettings | new-Itemproperty -name NewSignature -value $filename -propertytype string -force
get-item -path HKCU:\\Software\\Microsoft\\Office\\16.0\\Common\\MailSettings | new-Itemproperty -name ReplySignature -value $filename -propertytype string -force
Remove-ItemProperty -Path HKCU:\\Software\\Microsoft\\Office\\16.0\\Outlook\\Setup -Name "First-Run" -ErrorAction silentlycontinue
}
# Setting the regkeys for Outlook 2010 - Thank you AJWhite1970 for the 2010 registry keys
if (test-path "HKCU:\\Software\\Microsoft\\Office\\14.0\\Common\\General")
{
get-item -path HKCU:\\Software\\Microsoft\\Office\\14.0\\Common\\ General | new-Itemproperty -name Signatures -value signatures -propertytype string -force
get-item -path HKCU:\\Software\\Microsoft\\Office\\14.0\\Common\\ MailSettings | new-Itemproperty -name NewSignature -value $filename -propertytype string -force
get-item -path HKCU:\\Software\\Microsoft\\Office\\14.0\\Common\\ MailSettings | new-Itemproperty -name ReplySignature -value $filename -propertytype string -force
Remove-ItemProperty -Path HKCU:\\Software\\Microsoft\\Office\\14.0\\Outlook\\Setup -Name "First-Run" -ErrorAction silentlycontinue
}