Script für Outlook Signatur
Hallo, ich bin gerade dabei die Outlook Signaturen bei uns auf den neusten Stand zu bringen. Wir nutzen dafür ein Powershell-script das bei jedem Start geladen wird und eine Word-Vorlage mit den Daten aus der AD-auffüllt. Das funktioniert auch sehr gut.
Nun haben wir die Vorlage bekommen das wir zwei Signaturen benötigen, eine für neue Mails und eine für Antworten und Weiterleitungen.
Mein Problem ist nun das ich das Script nicht so geändert bekomme das mir zwei signaturen geladen werden.
Ich habe unten mal das Script angefügt vielleicht hat ja jemand eine Idee wie ich damit zwei Signaturen geladen bekomme. Würde mich sehr freuen nicht alle mit Hand zu ändern
Danke schonmal im Voraus.
MfG Sebastian
Nun haben wir die Vorlage bekommen das wir zwei Signaturen benötigen, eine für neue Mails und eine für Antworten und Weiterleitungen.
Mein Problem ist nun das ich das Script nicht so geändert bekomme das mir zwei signaturen geladen werden.
Ich habe unten mal das Script angefügt vielleicht hat ja jemand eine Idee wie ich damit zwei Signaturen geladen bekomme. Würde mich sehr freuen nicht alle mit Hand zu ändern
Danke schonmal im Voraus.
MfG Sebastian
# Custom variables
$UserDomain = $env:userdomain
if ($UserDomain -eq "GROEBERN")
{
$SignatureName = 'Signatur_long_GR'
# Pfad der Signatur auf AD-Server Attendorn
$SigSource = "\\x.y.z.de\SysVol\x.y.z.de\scripts\Scripte\signature\Signatur_long_GR.docx"
# Name der Signatur in HEX mit zwei Nullen am Ende
$inhalt = 0x73,0x00,0x6F,0x00,0x64,0x00,0x65,0x00,0x63,0x00,0x69,0x00,0x61,0x00,0x5F,0x00,0x61,0x00,0x74,0x00,0x74,0x00,0x65,0x00,0x6E,0x00,0x64,0x00,0x6F,0x00,0x72,0x00,0x6E,0x00,0x5F,0x00,0x67,0x00,0x72,0x00,0x6F,0x00,0x65,0x00,0x62,0x00,0x65,0x00,0x72,0x00,0x6E,0x00,0x00,0x00
}
$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 = '1' #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
if ($UserDomain -eq "GROEBERN")
{
$SigPath = '\Microsoft\Signatures'
$LocalSignaturePath = $AppData+$SigPath
$fullPathremove = $LocalSignaturePath+'\*'
remove-item $fullPathremove -recurse -force
}
$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()
$ADFirstName = $ADUser.FirstName
$ADLastName = $ADUser.LastName
$ADEmailAddress = $ADUser.mail
$ADTitle = $ADUser.title
$ADDescription = $ADUser.description
$ADTelePhoneNumber = $ADUser.TelephoneNumber
$ADPager = $ADUser.Pager
$ADfacsimileTelephoneNumber = $ADUser.facsimileTelephoneNumber
$ADMobile = $ADUser.mobile
$ADStreetAddress = $ADUser.streetaddress
$ADCity = $ADUser.l
$ADcoName = $ADUser.co
$ADPostalCode = $ADUser.PostalCode
$ADCompany = $ADUser.company
$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
Write-Output "Insert variables from Active Directory to rtf signature-file"
$MSWord = New-Object -ComObject word.application
$fullPath = $LocalSignaturePath+'\'+$SignatureName+'.docx'
[void]$MSWord.Documents.Open($fullPath)
# FirstName
If ($ADFirstName -ne '') {
$FindText = "FirstName"
$ReplaceText = $ADFirstName.ToString()
}
Else {
}
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )
# LastName
If ($ADLastName -ne '') {
$FindText = "LastName"
$ReplaceText = $ADLastName.ToString()
}
Else {
}
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )
# Title
If ($ADTitle -ne '') {
$FindText = "Title"
$ReplaceText = $ADTitle.ToString()
}
Else {
$FindText = "Title"
$ReplaceText = "".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 = "".ToString()
}
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )
# PostalCode
If ($ADPostalCode -ne '') {
$FindText = "PostalCode"
$ReplaceText = $ADPostalCode.ToString()
}
Else {
$FindText = "PostalCode"
$ReplaceText = "".ToString()
}
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )
# Company
If ($ADCompany -ne '') {
$FindText = "Company"
$ReplaceText = $ADCompany.ToString()
}
Else {
$FindText = "Company"
$ReplaceText = "".ToString()
}
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )
# coName
If ($ADcoName -ne '') {
$FindText = "coName"
If ($ADcoName -eq "Deutschland") {
$ReplaceText = "Germany".ToString()
}
Else {
$ReplaceText = $ADcoName.ToString()
}
}
Else {
$FindText = "coName"
$ReplaceText = "".ToString()
}
$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 )
# facsimileTelephoneNumber
If ($ADfacsimileTelephoneNumber -ne "") {
$FindText = "facsimileTelephoneNumber"
$ReplaceText = $ADfacsimileTelephoneNumber.ToString()
}
Else {
$FindText = "facsimileTelephoneNumber"
$ReplaceText = "".ToString()
}
$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 = "MobileNumber"
$ReplaceText = "".ToString()
}
$MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $ReplaceText, $ReplaceAll )
# Pager
If ($ADPager -ne "") {
$FindText = "Pager"
$ReplaceText = $ADPager.ToString()
}
Else {
$FindText = "Pager"
$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 "Remove forced signature for Office 2010"
Remove-ItemProperty HKCU:'\Software\Microsoft\Office\14.0\Common\MailSettings' -Name 'ReplySignature' -Force
Remove-ItemProperty HKCU:'\Software\Microsoft\Office\14.0\Common\MailSettings' -Name 'NewSignature' -Force
Write-Output "Setting Office 2010 signature as available"
$MSWord = New-Object -comobject word.application
$EmailOptions = $MSWord.EmailOptions
$EmailSignature = $EmailOptions.EmailSignature
$EmailSignatureEntries = $EmailSignature.EmailSignatureEntries
}
}
############################################################
# Signatur Ordnernummer auslesen
$signature_reg_version = ((Get-ItemProperty -Path HKCU:'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook\9375CFF0413111d3B88A00104B2A6676' -Name '{ED475418-B0D6-11D2-8C3B-00104B2A6676}').'{ED475418-B0D6-11D2-8C3B-00104B2A6676}')
# Binär in String
if ($signature_reg_version -eq "1")
{
$signature_reg_version = 1
}
ElseIf ($signature_reg_version -eq "2")
{
$signature_reg_version = 2
}
ElseIf ($signature_reg_version -eq "3")
{
$signature_reg_version = 3
}
ElseIf ($signature_reg_version -eq "4")
{
$signature_reg_version = 4
}
ElseIf ($signature_reg_version -eq "5")
{
$signature_reg_version = 5
}
ElseIf ($signature_reg_version -eq "6")
{
$signature_reg_version = 6
}
ElseIf ($signature_reg_version -eq "7")
{
$signature_reg_version = 7
}
ElseIf ($signature_reg_version -eq "8")
{
$signature_reg_version = 8
}
ElseIf ($signature_reg_version -eq "9")
{
$signature_reg_version = 9
}
# Erzeugen der Reg Schlüssel für New und Reply E-Mails
New-ItemProperty HKCU:'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook\9375CFF0413111d3B88A00104B2A6676\0000000'$signature_reg_version -Name 'New Signature' -Value ([byte[]]($inhalt)) -PropertyType 'Binary' -Force
New-ItemProperty HKCU:'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook\9375CFF0413111d3B88A00104B2A6676\0000000'$signature_reg_version -Name 'Reply-Forward Signature' -Value ([byte[]]($inhalt)) -PropertyType 'Binary' -Force
# Schliessen von Outlook, da es sonst geöffnet bleibt
Get-Process outlook | Foreach-Object { $_.CloseMainWindow() | Out-Null } | stop-process –force
Bitte markiere auch die Kommentare, die zur Lösung des Beitrags beigetragen haben
Kommentar vom Moderator Dani am 16.03.2019 um 11:16:30 Uhr
- Formatierung hinzugefügt.
- Echtdaten ersetzt.
- Echtdaten ersetzt.
Content-ID: 429048
Url: https://administrator.de/contentid/429048
Ausgedruckt am: 22.11.2024 um 18:11 Uhr
3 Kommentare
Neuester Kommentar
Zitat von @s.fromm:
$SigSource = "\\x.y.z.de\SysVol\x.y.z.de\scripts\Scripte\signature\Signatur_long_GR.docx"
na, wenn deine Frage in Verbindung mit den Infos keine Bewerbungen hageln lässt...$SigSource = "\\x.y.z.de\SysVol\x.y.z.de\scripts\Scripte\signature\Signatur_long_GR.docx"
Zitat von @Kraemer:
na, wenn deine Frage in Verbindung mit den Infos keine Bewerbungen hageln lässt...
Wohl eher Kündigungen ...na, wenn deine Frage in Verbindung mit den Infos keine Bewerbungen hageln lässt...
https://www.saechsische.de/autozulieferer-ist-zahlungsunfaehig-3417877.h ...