none
Firma Outlook 2007/2010 tramite PowerShell RRS feed

  • Domanda

  • Ciao ho un problema con uno script di powershell

    Sto seguendo questa guida, http://www.windowserver.it/Articoli/ExchangeServer2010/FirmaOutlookedOWAviaActiveDirectory.aspx seguendo passo passo le modifiche da eseguire.

    Quanndo lancio lo script per testare il risultato, prima di deployarlo con le policy, mi compare un messaggio di errore bello rosso.

    New-Object : Impossibile caricare il tipo COM word.application.12.
    In \\sbsdc1\signatures\.\Signature.ps1:108 car:22
    +  $MSWord = New-Object <<<<  -com word.application.12
        + CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentException
        + FullyQualifiedErrorId : CannotLoadComObjectType,Microsoft.PowerShell.Commands.NewObjectCommand

    Impossibile trovare la proprietà 'NewMessageSignature' in questo oggetto. Verificare che esista e sia impostabile.
    In \\sbsdc1\signatures\.\Signature.ps1:112 car:18
    +  $EmailSignature. <<<< NewMessageSignature=$CompanyName
        + CategoryInfo          : InvalidOperation: (NewMessageSignature:String) [], RuntimeException
        + FullyQualifiedErrorId : PropertyNotFound

    Impossibile chiamare un metodo su un'espressione con valore null.
    In \\sbsdc1\signatures\.\Signature.ps1:113 car:14
    +  $MSWord.Quit <<<< ()
        + CategoryInfo          : InvalidOperation: (Quit:String) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull

    New-Object : Impossibile caricare il tipo COM word.application.
    In \\sbsdc1\signatures\.\Signature.ps1:121 car:21
    + $MSWord = New-Object <<<<  -com word.application
        + CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentException
        + FullyQualifiedErrorId : CannotLoadComObjectType,Microsoft.PowerShell.Commands.NewObjectCommand

    Impossibile trovare la proprietà 'ReplyMessageSignature' in questo oggetto. Verificare che esista e sia impostabile.
    In \\sbsdc1\signatures\.\Signature.ps1:125 car:17
    + $EmailSignature. <<<< ReplyMessageSignature=$CompanyName
        + CategoryInfo          : InvalidOperation: (ReplyMessageSignature:String) [], RuntimeException
        + FullyQualifiedErrorId : PropertyNotFound

    Impossibile chiamare un metodo su un'espressione con valore null.
    In \\sbsdc1\signatures\.\Signature.ps1:126 car:13
    + $MSWord.Quit <<<< ()
        + CategoryInfo          : InvalidOperation: (Quit:String) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull

    Ho provato a venirne a capo ma con gli script non sono ferrato.

    Io penso che tutti gli errore, ad eccezione del primo sono errori sequenziali, nel senso:

    non completando il primo step, automaticamente non può portare a termine gli altri.

    Dove sbaglio?

    cosa mi manca?

    Atturalment la piattaforma è Exchange 2010 Sp3

    Client OL2010 Su Win7 Pro.

    Ogni aiuto è prezioso.

    Grazie,.

    • Modificato Anca Popa lunedì 11 novembre 2013 15:22 formattazione testo
    martedì 5 novembre 2013 14:10

Risposte

  • l'errore riguarda proprio interops ... 

    verificane la corretta installazione, verifica di avere il framework corretto.

    Se non va prova su un altra macchina

    Questo è quello che ho in produzione da me e una paio di clienti...

    #Custom variables
    $CompanyName = ‘iQuad’
    $DomainName = ‘iqd.local’
    
    
    $SigSource = “\\$DomainName\netlogon\sig_files\$CompanyName”
    $ForceSignatureNew = ’1' #When the signature are forced the signature are enforced as default signature for new messages the next time the script runs. 0 = no force, 1 = force
    $ForceSignatureReplyForward = ’1' #When the signature are forced the signature are enforced as default signature for reply/forward messages the next time the script runs. 0 = no force, 1 = force
    
    #Environment variables
    $AppData=(Get-Item env:appdata).value
    $SigPath = ‘\Microsoft\Signatures’
    $LocalSignaturePath = $AppData+$SigPath
    $RemoteSignaturePathFull = $SigSource+’\'+$CompanyName+’.docx’
    $ExchPath = '\\EX1\Signatures\'
    
    
    #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
    $ADTelePhoneNumber = $ADUser.telephoneNumber
    $ADdescription = $ADuser.description
    $ADFax = $ADuser.facsimileTelephoneNumber
    $ADMobile = $ADuser.mobile
    $ADDepartment = $ADuser.department
    
    
    #Setting registry information for the current user
    $CompanyRegPath = “HKCU:\Software\”+$CompanyName
    
    if (Test-Path $CompanyRegPath)
    {}
    else
    {New-Item -path “HKCU:\Software” -name $CompanyName}
    
    if (Test-Path $CompanyRegPath’\Outlook Signature Settings’)
    {}
    else
    {New-Item -path $CompanyRegPath -name “Outlook Signature Settings”}
    
    $SigVersion = (gci $RemoteSignaturePathFull).LastWriteTime #When was the last time the signature was written
    $ForcedSignatureNew = (Get-ItemProperty $CompanyRegPath’\Outlook Signature Settings’).ForcedSignatureNew
    $ForcedSignatureReplyForward = (Get-ItemProperty $CompanyRegPath’\Outlook Signature Settings’).ForcedSignatureReplyForward
    $SignatureVersion = (Get-ItemProperty $CompanyRegPath’\Outlook Signature Settings’).SignatureVersion
    Set-ItemProperty $CompanyRegPath’\Outlook Signature Settings’ -name SignatureSourceFiles -Value $SigSource
    $SignatureSourceFiles = (Get-ItemProperty $CompanyRegPath’\Outlook Signature Settings’).SignatureSourceFiles
    
    #Forcing signature for new messages if enabled
    if ($ForcedSignatureNew -eq ’1')
    {
    #Set company signature as default for New messages
    $MSWord = New-Object -com word.application
    $EmailOptions = $MSWord.EmailOptions
    $EmailSignature = $EmailOptions.EmailSignature
    $EmailSignatureEntries = $EmailSignature.EmailSignatureEntries
    $EmailSignature.NewMessageSignature=$CompanyName
    $MSWord.Quit()
    }
    
    #Forcing signature for reply/forward messages if enabled
    if ($ForcedSignatureReplyForward -eq ’0)
    {
    #Set company signature as default for Reply/Forward messages
    
     $MSWord = New-Object -com word.application
     $EmailOptions = $MSWord.EmailOptions
     $EmailSignature = $EmailOptions.EmailSignature
     $EmailSignatureEntries = $EmailSignature.EmailSignatureEntries
     $EmailSignature.ReplyMessageSignature=$CompanyName
    
     $MSWord.Quit()
    }
    
    #Copying signature sourcefiles and creating signature if signature-version are different from local version
    if ($SignatureVersion -eq $SigVersion){}
    else
    {
    #Copy signature templates from domain to local Signature-folder
    Copy-Item “$SignatureSourceFiles\*” $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 -com word.application
    $fullPath = $LocalSignaturePath+’\'+$CompanyName+’.docx’
    $MSWord.Documents.Open($fullPath)
    
    $FindText = “DisplayName”
    $ReplaceText = $ADDisplayName.ToString()
    $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,	$MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap,	$Format, $ReplaceText, $ReplaceAll	)
    
    $FindText = “Title”
    $ReplaceText = $ADTitle.ToString()
    $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,	$MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap,	$Format, $ReplaceText, $ReplaceAll	)
    
    # $MSWord.Selection.Find.Execute(“PostaEL”)
    $FindText = “PostaEL”
    $ReplaceText = $ADEmailAddress.ToString()
    $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,	$MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap,	$Format, $ReplaceText, $ReplaceAll	)
    
    
    $FindText = “TelePhoneNumber”
    $ReplaceText = $ADTelePhoneNumber.ToString()
    $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,	$MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap,	$Format, $ReplaceText, $ReplaceAll	)
    
    $FindText = “facsimileTelephoneNumber”
    $ReplaceText = $ADFax.ToString()
    $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,	$MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap,	$Format, $ReplaceText, $ReplaceAll	)
    
    $FindText = “BlogIQ”
    $ReplaceText = $ADDepartment.ToString()
    $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,	$MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap,	$Format, $ReplaceText, $ReplaceAll	)
    
    
    # $MSWord.ActiveDocument.Hyperlinks.Add($MSWord.Selection.Range, “mailto:”+$ADEmailAddress.ToString(), $missing, $missing, $ADEmailAddress.ToString())
    
    $MSWord.ActiveDocument.Save()
    $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], “wdFormatFilteredHTML”);
    [ref]$BrowserLevel = “microsoft.office.interop.word.WdBrowserLevel” -as [type]
    
    $MSWord.ActiveDocument.WebOptions.OrganizeInFolder = $true
    $MSWord.ActiveDocument.WebOptions.UseLongFileNames = $true
    $MSWord.ActiveDocument.WebOptions.BrowserLevel = $BrowserLevel::wdBrowserLevelMicrosoftInternetExplorer6
    $path = $LocalSignaturePath+’\'+$CompanyName+”.htm”
    
    $MSWord.ActiveDocument.saveas([ref]$path, [ref]$saveFormat)
    
    # Save html file with username from AD (OWA)
    $pathOWA = $LocalSignaturePath+’\'+$UserName+”.htm”
    $MSWord.ActiveDocument.saveas([ref]$pathOWA, [ref]$saveFormat)
    Copy-Item “$LocalSignaturePath\$UserName.htm” "$ExchPath" -Recurse -Force
    
    
    
    # Saving rtf and txt 
    
    $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], “wdFormatRTF”);
    $path = $LocalSignaturePath+’\'+$CompanyName+”.rtf”
    $MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$saveFormat)
    
    $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], “wdFormatText”);
    $path = $LocalSignaturePath+’\'+$CompanyName+”.rtf”
    $MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$saveFormat)
    
    $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], “wdFormatText”);
    $path = $LocalSignaturePath+’\'+$CompanyName+”.txt”
    $MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$saveFormat)
    
    $MSWord.ActiveDocument.Close()
    
    $MSWord.Quit()
    
    }
    
    #Stamp registry-values for Outlook Signature Settings if they doesn`t match the initial script variables. Note that these will apply after the second script run when changes are made in the “Custom variables”-section.
    if ($ForcedSignatureNew -eq $ForceSignatureNew){}
    else
    {Set-ItemProperty $CompanyRegPath’\Outlook Signature Settings’ -name ForcedSignatureNew -Value $ForceSignatureNew}
    
    if ($ForcedSignatureReplyForward -eq $ForceSignatureReplyForward){}
    else
    {Set-ItemProperty $CompanyRegPath’\Outlook Signature Settings’ -name ForcedSignatureReplyForward -Value $ForceSignatureReplyForward}
    
    if ($SignatureVersion -eq $SigVersion){}
    else
    {Set-ItemProperty $CompanyRegPath’\Outlook Signature Settings’ -name SignatureVersion -Value $SigVersion}
    

     

    Andrea Gallazzi
    www.windowserver.it - blog: andreagx.blogspot.com
    This posting is provided AS IS with no warranties, and confers no rights

    • Proposto come risposta Anca Popa venerdì 8 novembre 2013 22:22
    • Contrassegnato come risposta Anca Popa lunedì 11 novembre 2013 15:21
    mercoledì 6 novembre 2013 09:28

Tutte le risposte

  • Hai installato gli Assembly di interoperabilità?

    Magari dai una letta direttamente qui:

    http://andreagx.blogspot.it/2012/09/firma-di-outlook-e-owa-basata-sulle.html


    Andrea Gallazzi
    www.windowserver.it - blog: andreagx.blogspot.com
    This posting is provided AS IS with no warranties, and confers no rights


    • Modificato Andreagx martedì 5 novembre 2013 17:31 add info
    martedì 5 novembre 2013 17:25
  • si le ho installate. Ho anche cancellato il profilo utente sia a livello macchina sia a livello Ol ma non è cambiato nulla.

    non saprei capire dove sto sbagliando.

    Ho sbagliato a mettere gli errori.

    Riporto gli errori corretti:

    PS C:\hot>
    PS C:\hot> .\Signature.ps1
    New-Object : Impossibile caricare il tipo COM word.application.
    In C:\hot\Signature.ps1:108 car:21
    + $MSWord = New-Object <<<<  -com word.application
        + CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentException
        + FullyQualifiedErrorId : CannotLoadComObjectType,Microsoft.PowerShell.Commands.NewObjectCommand

    Impossibile trovare la proprietà 'NewMessageSignature' in questo oggetto. Verificare che esista e sia impostabile.
    In C:\hot\Signature.ps1:112 car:17
    + $EmailSignature. <<<< NewMessageSignature=$CompanyName
        + CategoryInfo          : InvalidOperation: (NewMessageSignature:String) [], RuntimeException
        + FullyQualifiedErrorId : PropertyNotFound

    Impossibile chiamare un metodo su un'espressione con valore null.
    In C:\hot\Signature.ps1:113 car:13
    + $MSWord.Quit <<<< ()
        + CategoryInfo          : InvalidOperation: (Quit:String) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull

    New-Object : Impossibile caricare il tipo COM word.application.
    In C:\hot\Signature.ps1:121 car:21
    + $MSWord = New-Object <<<<  -com word.application
        + CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentException
        + FullyQualifiedErrorId : CannotLoadComObjectType,Microsoft.PowerShell.Commands.NewObjectCommand

    Impossibile trovare la proprietà 'ReplyMessageSignature' in questo oggetto. Verificare che esista e sia impostabile.
    In C:\hot\Signature.ps1:125 car:17
    + $EmailSignature. <<<< ReplyMessageSignature=$CompanyName
        + CategoryInfo          : InvalidOperation: (ReplyMessageSignature:String) [], RuntimeException
        + FullyQualifiedErrorId : PropertyNotFound

    Impossibile chiamare un metodo su un'espressione con valore null.
    In C:\hot\Signature.ps1:126 car:13
    + $MSWord.Quit <<<< ()
        + CategoryInfo          : InvalidOperation: (Quit:String) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull


    • Modificato kekkorainone martedì 5 novembre 2013 20:50 errata corrige
    martedì 5 novembre 2013 19:57
  • Word è installato vero? 

    segui lo script come amministratore?

    BTW l'errore riguarda proprio interops 


    Andrea Gallazzi
    www.windowserver.it - blog: andreagx.blogspot.com
    This posting is provided AS IS with no warranties, and confers no rights

    mercoledì 6 novembre 2013 08:18
  • Ciao,

    Tutto si Word ed esecuzione come amministratore. Dato che è una macchina test, posso anche tentare il ripristino.

    come da tua guida, ho cambiato i valori dei seguenti parametri:

    Domain name

    company name

    exchangeserver path.

    magari altre cose?

    mercoledì 6 novembre 2013 08:58
  • l'errore riguarda proprio interops ... 

    verificane la corretta installazione, verifica di avere il framework corretto.

    Se non va prova su un altra macchina

    Questo è quello che ho in produzione da me e una paio di clienti...

    #Custom variables
    $CompanyName = ‘iQuad’
    $DomainName = ‘iqd.local’
    
    
    $SigSource = “\\$DomainName\netlogon\sig_files\$CompanyName”
    $ForceSignatureNew = ’1' #When the signature are forced the signature are enforced as default signature for new messages the next time the script runs. 0 = no force, 1 = force
    $ForceSignatureReplyForward = ’1' #When the signature are forced the signature are enforced as default signature for reply/forward messages the next time the script runs. 0 = no force, 1 = force
    
    #Environment variables
    $AppData=(Get-Item env:appdata).value
    $SigPath = ‘\Microsoft\Signatures’
    $LocalSignaturePath = $AppData+$SigPath
    $RemoteSignaturePathFull = $SigSource+’\'+$CompanyName+’.docx’
    $ExchPath = '\\EX1\Signatures\'
    
    
    #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
    $ADTelePhoneNumber = $ADUser.telephoneNumber
    $ADdescription = $ADuser.description
    $ADFax = $ADuser.facsimileTelephoneNumber
    $ADMobile = $ADuser.mobile
    $ADDepartment = $ADuser.department
    
    
    #Setting registry information for the current user
    $CompanyRegPath = “HKCU:\Software\”+$CompanyName
    
    if (Test-Path $CompanyRegPath)
    {}
    else
    {New-Item -path “HKCU:\Software” -name $CompanyName}
    
    if (Test-Path $CompanyRegPath’\Outlook Signature Settings’)
    {}
    else
    {New-Item -path $CompanyRegPath -name “Outlook Signature Settings”}
    
    $SigVersion = (gci $RemoteSignaturePathFull).LastWriteTime #When was the last time the signature was written
    $ForcedSignatureNew = (Get-ItemProperty $CompanyRegPath’\Outlook Signature Settings’).ForcedSignatureNew
    $ForcedSignatureReplyForward = (Get-ItemProperty $CompanyRegPath’\Outlook Signature Settings’).ForcedSignatureReplyForward
    $SignatureVersion = (Get-ItemProperty $CompanyRegPath’\Outlook Signature Settings’).SignatureVersion
    Set-ItemProperty $CompanyRegPath’\Outlook Signature Settings’ -name SignatureSourceFiles -Value $SigSource
    $SignatureSourceFiles = (Get-ItemProperty $CompanyRegPath’\Outlook Signature Settings’).SignatureSourceFiles
    
    #Forcing signature for new messages if enabled
    if ($ForcedSignatureNew -eq ’1')
    {
    #Set company signature as default for New messages
    $MSWord = New-Object -com word.application
    $EmailOptions = $MSWord.EmailOptions
    $EmailSignature = $EmailOptions.EmailSignature
    $EmailSignatureEntries = $EmailSignature.EmailSignatureEntries
    $EmailSignature.NewMessageSignature=$CompanyName
    $MSWord.Quit()
    }
    
    #Forcing signature for reply/forward messages if enabled
    if ($ForcedSignatureReplyForward -eq ’0)
    {
    #Set company signature as default for Reply/Forward messages
    
     $MSWord = New-Object -com word.application
     $EmailOptions = $MSWord.EmailOptions
     $EmailSignature = $EmailOptions.EmailSignature
     $EmailSignatureEntries = $EmailSignature.EmailSignatureEntries
     $EmailSignature.ReplyMessageSignature=$CompanyName
    
     $MSWord.Quit()
    }
    
    #Copying signature sourcefiles and creating signature if signature-version are different from local version
    if ($SignatureVersion -eq $SigVersion){}
    else
    {
    #Copy signature templates from domain to local Signature-folder
    Copy-Item “$SignatureSourceFiles\*” $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 -com word.application
    $fullPath = $LocalSignaturePath+’\'+$CompanyName+’.docx’
    $MSWord.Documents.Open($fullPath)
    
    $FindText = “DisplayName”
    $ReplaceText = $ADDisplayName.ToString()
    $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,	$MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap,	$Format, $ReplaceText, $ReplaceAll	)
    
    $FindText = “Title”
    $ReplaceText = $ADTitle.ToString()
    $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,	$MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap,	$Format, $ReplaceText, $ReplaceAll	)
    
    # $MSWord.Selection.Find.Execute(“PostaEL”)
    $FindText = “PostaEL”
    $ReplaceText = $ADEmailAddress.ToString()
    $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,	$MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap,	$Format, $ReplaceText, $ReplaceAll	)
    
    
    $FindText = “TelePhoneNumber”
    $ReplaceText = $ADTelePhoneNumber.ToString()
    $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,	$MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap,	$Format, $ReplaceText, $ReplaceAll	)
    
    $FindText = “facsimileTelephoneNumber”
    $ReplaceText = $ADFax.ToString()
    $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,	$MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap,	$Format, $ReplaceText, $ReplaceAll	)
    
    $FindText = “BlogIQ”
    $ReplaceText = $ADDepartment.ToString()
    $MSWord.Selection.Find.Execute($FindText, $MatchCase, $MatchWholeWord,	$MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap,	$Format, $ReplaceText, $ReplaceAll	)
    
    
    # $MSWord.ActiveDocument.Hyperlinks.Add($MSWord.Selection.Range, “mailto:”+$ADEmailAddress.ToString(), $missing, $missing, $ADEmailAddress.ToString())
    
    $MSWord.ActiveDocument.Save()
    $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], “wdFormatFilteredHTML”);
    [ref]$BrowserLevel = “microsoft.office.interop.word.WdBrowserLevel” -as [type]
    
    $MSWord.ActiveDocument.WebOptions.OrganizeInFolder = $true
    $MSWord.ActiveDocument.WebOptions.UseLongFileNames = $true
    $MSWord.ActiveDocument.WebOptions.BrowserLevel = $BrowserLevel::wdBrowserLevelMicrosoftInternetExplorer6
    $path = $LocalSignaturePath+’\'+$CompanyName+”.htm”
    
    $MSWord.ActiveDocument.saveas([ref]$path, [ref]$saveFormat)
    
    # Save html file with username from AD (OWA)
    $pathOWA = $LocalSignaturePath+’\'+$UserName+”.htm”
    $MSWord.ActiveDocument.saveas([ref]$pathOWA, [ref]$saveFormat)
    Copy-Item “$LocalSignaturePath\$UserName.htm” "$ExchPath" -Recurse -Force
    
    
    
    # Saving rtf and txt 
    
    $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], “wdFormatRTF”);
    $path = $LocalSignaturePath+’\'+$CompanyName+”.rtf”
    $MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$saveFormat)
    
    $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], “wdFormatText”);
    $path = $LocalSignaturePath+’\'+$CompanyName+”.rtf”
    $MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$saveFormat)
    
    $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], “wdFormatText”);
    $path = $LocalSignaturePath+’\'+$CompanyName+”.txt”
    $MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$saveFormat)
    
    $MSWord.ActiveDocument.Close()
    
    $MSWord.Quit()
    
    }
    
    #Stamp registry-values for Outlook Signature Settings if they doesn`t match the initial script variables. Note that these will apply after the second script run when changes are made in the “Custom variables”-section.
    if ($ForcedSignatureNew -eq $ForceSignatureNew){}
    else
    {Set-ItemProperty $CompanyRegPath’\Outlook Signature Settings’ -name ForcedSignatureNew -Value $ForceSignatureNew}
    
    if ($ForcedSignatureReplyForward -eq $ForceSignatureReplyForward){}
    else
    {Set-ItemProperty $CompanyRegPath’\Outlook Signature Settings’ -name ForcedSignatureReplyForward -Value $ForceSignatureReplyForward}
    
    if ($SignatureVersion -eq $SigVersion){}
    else
    {Set-ItemProperty $CompanyRegPath’\Outlook Signature Settings’ -name SignatureVersion -Value $SigVersion}
    

     

    Andrea Gallazzi
    www.windowserver.it - blog: andreagx.blogspot.com
    This posting is provided AS IS with no warranties, and confers no rights

    • Proposto come risposta Anca Popa venerdì 8 novembre 2013 22:22
    • Contrassegnato come risposta Anca Popa lunedì 11 novembre 2013 15:21
    mercoledì 6 novembre 2013 09:28
  • ok riverifico e ti aggiorno.

    Grazie dell'aiuto.

    mercoledì 6 novembre 2013 10:01
  • Ciao,

    Evidenzio l'intervento di Andrea in attesa di ulteriori feedback (speriamo positivi).

    Grazie a tutti della partecipazione nel Forum di Exchange :-)


    Anca Popa Follow ForumTechNetIt on Twitter

    Microsoft offre questo servizio gratuitamente, per aiutare gli utenti e aumentare il database dei prodotti e delle tecnologie. Il contenuto viene fornito “così come è” e non comporta alcuna responsabilità da parte dell'azienda.

    lunedì 11 novembre 2013 15:20
  • Se non hai risolto prova con questa versione:

    https://gist.github.com/andreagx/9067652

    Ciao ciao


    Andrea Gallazzi
    windowserver.it - blog: andreagx.blogspot.com
    This posting is provided AS IS with no warranties, and confers no rights.


    • Modificato Andreagx martedì 11 marzo 2014 13:04
    martedì 11 marzo 2014 13:04