{"id":4012,"date":"2019-03-11T10:04:34","date_gmt":"2019-03-11T10:04:34","guid":{"rendered":"https:\/\/pariswells.com\/blog\/?p=4012"},"modified":"2023-06-21T23:20:44","modified_gmt":"2023-06-21T23:20:44","slug":"how-to-use-powershell-to-mail-merge-outlook-signature-for-users-out-of-active-directory","status":"publish","type":"post","link":"https:\/\/pariswells.com\/blog\/research\/how-to-use-powershell-to-mail-merge-outlook-signature-for-users-out-of-active-directory","title":{"rendered":"How to Use Powershell to Mail Merge Outlook Signature for Users out of Active Directory"},"content":{"rendered":"\n<p>Script 1<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">#Get Active Directory information for current user\n\n$UserName = $env:username\n\n$Filter = \u201c(&amp;(objectCategory=User)(samAccountName=$UserName))\u201d\n\n$Searcher = New-Object System.DirectoryServices.DirectorySearcher\n\n$Searcher.Filter = $Filter\n\n$ADUserPath = $Searcher.FindOne()\n\n$ADUser = $ADUserPath.GetDirectoryEntry()\n\n$ADDisplayName = $ADUser.name\n\n$ADTitle = $ADUser.title\n\n$ADOffice = $ADUser.physicalDeliveryOfficeName\n\n$script:ADMobileNumber = $script:ADUser.mobile\n\n$ADTelePhoneNumber = $ADUser.telephoneNumber\n\n$ADExtension1 = $ADUser.extensionAttribute1\n\n$ADExtension2 = $ADUser.extensionAttribute2\n\n$ADExtension3 = $ADUser.extensionAttribute3\n\n \n\n#Additional Variables\n\n$AppData=(Get-Item env:appdata).value\n\n$SigPath = \u2018\\Microsoft\\Signatures\u2019\n\n$LocalSignaturePath = $AppData+$SigPath\n\n$SignatureName = '%signaturename%'\n\n$DomainName = '%domainname%'\n\n$fulladdetails = $ADDisplayName+$ADExtension1+$ADTitle+$ADOffice+$script:ADMobileNumber+$ADTelePhoneNumber\n\n \n\n#Check if signature directory exists and, if not, update it\n\nIf (Test-Path $LocalSignaturePath)\n\n{}\n\nElse\n\n{New-Item $LocalSignaturePath -type directory}\n\n \n\nWrite-host $fulladdetails\n\n \n\n#Check if  Signature has changed\n\nIf (\"$fulladdetails\" -eq \"$SigChkDetails\")\n\n{ Exit }\n\nElse\n\n{  }\n\n \n\n#Delete old signature files\n\nRemove-Item \"$LocalSignaturePath\\$ADDisplayName.htm\" -Recurse -Force\n\n \n\n#Copy over signature template\n\n$SigSource = \u201c\\\\path\\to\\signature\\source\"\n\n$filename = \"\\\\path\\to\\signature\\template.htm\"\n\n$filename2 = \"\\\\path\\to\\logo.jpg\"\n\n \n\nCopy-Item $filename $LocalSignaturePath -Recurse -Force\n\nCopy-Item $filename2 $LocalSignaturePath -Recurse -Force\n \n\n#Modify Signature and Insert Variables\n\n(Get-Content $LocalSignaturePath\\template.htm) -replace 'FullName', $ADDisplayName | Set-Content $LocalSignaturePath\\template.htm\n\n(Get-Content $LocalSignaturePath\\template.htm) -replace 'PositionTitle', $ADTitle | Set-Content $LocalSignaturePath\\template.htm\n\n(Get-Content $LocalSignaturePath\\template.htm) -replace 'PhoneNumber', $ADTelePhoneNumber | Set-Content $LocalSignaturePath\\template.htm\n\n \n\nIf(!$script:ADMobileNumber -or !$ADExtension2){\n\n(Get-Content $LocalSignaturePath\\template.htm) -replace '&lt;b>M&lt;\/b> MobileNumber', $NULL | Set-Content $LocalSignaturePath\\template.htm}\n\nELSE\n\n{(Get-Content $LocalSignaturePath\\template.htm) -replace 'MobileNumber', $script:ADMobileNumber | Set-Content $LocalSignaturePath\\template.htm}\n\n \n\nIf(!$ADExtension1){\n\n(Get-Content $LocalSignaturePath\\template.htm) -replace ', Qualification', $NULL | Set-Content $LocalSignaturePath\\template.htm}\n\nELSE\n\n{(Get-Content $LocalSignaturePath\\template.htm) -replace 'Qualification', $ADExtension1 | Set-Content $LocalSignaturePath\\template.htm}\n\n \n\nIf($ADOffice -ne 'Singapore'){\n\nIf(!$ADExtension3){\n\n(Get-Content $LocalSignaturePath\\template.htm) -replace 'ImageRow', '&lt;img src=\".\/logo.jpg\" width=\"259\" height=\"74\" border=\"0\" \/>' | Set-Content $LocalSignaturePath\\template.htm}\n\n}ELSE\n\n{(Get-Content $LocalSignaturePath\\template.htm) -replace 'ImageRow', $null | Set-Content $LocalSignaturePath\\template.htm}\n\n\n\n \n\nRename-Item -Path $LocalSignaturePath\\template.htm -NewName \"$ADDisplayName.htm\"\n\n \n\n#Set company signature as default for New messages\n\n[Void] [Reflection.Assembly]::LoadWithPartialName(\"Microsoft.Office.Interop.Word\")\n\n$MSWord = New-Object -com word.application\n\n$EmailOptions = $MSWord.EmailOptions\n\n$EmailSignature = $EmailOptions.EmailSignature\n\n$EmailSignatureEntries = $EmailSignature.EmailSignatureEntries\n\n$EmailSignature.NewMessageSignature=$ADDisplayName\n\n$MSWord.Quit()\n\n \n\n#Set company signature as default for Reply messages\n\n[Void] [Reflection.Assembly]::LoadWithPartialName(\"Microsoft.Office.Interop.Word\")\n\n$MSWord = New-Object -com word.application\n\n$EmailOptions = $MSWord.EmailOptions\n\n$EmailSignature = $EmailOptions.EmailSignature\n\n$EmailSignatureEntries = $EmailSignature.EmailSignatureEntries\n\n$EmailSignature.ReplyMessageSignature=$ADDisplayName\n\n$MSWord.Quit() <\/code><\/pre>\n\n\n\n<p>Script 2<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">&lt;#\r\n.SYNOPSIS\r\nSets your email signature according to company policy\r\n\r\n.DESCRIPTION\r\nThis script is designed to be run as a logon script, and it will create the proper files for the Outlook\r\nemail signature in Outlook 2010\/2013\/2016. It executes an AD query, populates the proper fields, then pumps\r\ndata into a word document which is saved as a rtf, txt, and htm. It then forcefully sets the registry settings\r\nso users cant change it.\r\nRequires:\r\n.INPUTS\r\n.OUTPUTS\r\n%appdata%\\Microsoft\\Signatures\\v2.txt\r\n%appdata%\\Microsoft\\Signatures\\v2.htm\r\n%appdata%\\Microsoft\\Signatures\\v2.rtf\r\n%appdata%\\Microsoft\\Signatures\\v2_files\r\n.NOTES\r\n  Version:        1.0\r\n  Author:         Buido.Signature@gmail.com\r\n  Creation Date:  11\/11\/2017\r\n  Purpose\/Change: \r\n.EXAMPLE\r\n.ChangeLog\r\n#>\r\n\r\nfunction Create-Log\r\n{\r\n    [cmdletbinding()]\r\n    param(\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=0)]\r\n    [validatenotnullorempty()]\r\n    [string]$strComputerName\r\n    )\r\n\r\n    $strLogLocation = Get-LogLocation -strComputerName $strComputerName\r\n    if ($(test-path $strLogLocation) -eq $false)\r\n    {\r\n        New-Item -Path $strLogLocation -ItemType File | Out-Null\r\n    }\r\n}\r\n\r\nfunction Get-LogLocation\r\n{\r\n    [cmdletbinding()]\r\n    param(\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=0)]\r\n    [validatenotnullorempty()]\r\n    [string]$strComputerName\r\n    )\r\n    if ($(test-path $($env:appdata + \"\\Email-SignatureScript\")) -eq $false)\r\n    {\r\n        New-Item -Path $($env:appdata + \"\\Email-SignatureScript\") -ItemType directory | Out-Null\r\n    }\r\n\r\n    $strLogLocation = $env:appdata + \"\\Email-SignatureScript\\\" + $strComputerName + \".txt\"\r\n    Return $strLogLocation\r\n}\r\n\r\nfunction Log-This\r\n{\r\n    [cmdletbinding()]\r\n    param(\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=0)]\r\n    [validatenotnullorempty()]\r\n    [string]$strLogLocation,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=0)]\r\n    [validatenotnullorempty()]\r\n    [string]$strErrorMessage\r\n    )\r\n\r\n    ac -path $strLogLocation -Value \"$strErrorMessage on $(get-date)\"\r\n}\r\n\r\nfunction Set-CompanyInfo\r\n{\r\n    [cmdletbinding()]\r\n    param(\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=0)]\r\n    [validatenotnullorempty()]\r\n    [string]$strLogLocation,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=1)]\r\n    [validatenotnullorempty()]\r\n    [string]$strADCompany\r\n    )\r\n    try\r\n    {\r\n        $objCompanyDetails = New-Object System.Object\r\n        $objHyperlink = \"www.google.com\", \"https:\/\/www.Google.com\"\r\n        $strPicture = \"$env:appdata\\Microsoft\\Stationery\\google.png\"\r\n        $Signame = \"google Signature v1\"\r\n\r\n        Switch -regex ($strADCompany)\r\n        {\r\n            \"\\b(Google)\\b\"\r\n            {\r\n             \r\n                $objHyperlink = \"www.google.com\", \"https:\/\/www.Google.com\"\r\n                $strPicture = \"$env:appdata\\Microsoft\\Stationery\\google.png\"\r\n                $Signame = \"google Signature v1\"\r\n            }\r\n            \"\\b(Apple)\\b\" \r\n            {\r\n                $objHyperlink = \"http:\/\/www.Apple.com\", \"www.Apple.com\"\r\n                $strPicture = \"$env:appdata\\Microsoft\\Stationery\\Apple.png\"\r\n                $Signame = \"Apple Signature v1\"\r\n            }\r\n            \"\\b(Amazon)\\b\"\r\n            {\r\n                $objHyperlink = \"http:\/\/www.Amazon.com\", \"www.Amazon.com\"\r\n                $strPicture = \"$env:appdata\\Microsoft\\Stationery\\Amazon.png\"\r\n                $Signame = \"Amazon Signature v1\"\r\n            }\r\n            \"\\b(Microsoft)\\b\" \r\n            {\r\n                $objHyperlink = \"http:\/\/www.Microsoft.com\", \"www.Microsoft.com\"\r\n                $strPicture = \"$env:appdata\\Microsoft\\Stationery\\Microsoft.png\"\r\n                $Signame = \"Microsoft Signature v1\"\r\n            }\r\n            default {}\r\n        }\r\n\r\n        $objCompanyDetails | Add-Member -MemberType NoteProperty -Name \"Hyperlink\" -Value $objHyperlink\r\n        $objCompanyDetails | Add-Member -MemberType NoteProperty -Name \"Picture\" -Value $strPicture\r\n        $objCompanyDetails | Add-Member -MemberType NoteProperty -Name \"Signame\" -Value $Signame\r\n    }\r\n    catch\r\n    {\r\n        $errItemName = $_.Exception.ItemName\r\n        Log-This -strLogLocation $strLogLocation -strErrorMessage \"$errItemName - $_\"\r\n    }\r\n\r\n    Return $objCompanyDetails\r\n}\r\n\r\nfunction Set-CountryInfo\r\n{\r\n    [cmdletbinding()]\r\n    param(\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=0)]\r\n    [validatenotnullorempty()]\r\n    [string]$strLogLocation,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=1)]\r\n    [validatenotnullorempty()]\r\n    [string]$strCountry,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=1)]\r\n    [validatenotnullorempty()]\r\n    [string]$strADCompany\r\n    )\r\n    try\r\n    {\r\n        $objCountryDetails = New-Object System.Object\r\n        $intFontSize = $null\r\n        $strLine1 = $null\r\n        $strLine1 = $null\r\n\r\n        Switch ($strCountry)\r\n        {\r\n            \"United Kingdom\"\r\n            {\r\n                if ($strADCompany -match \"\\b(google)\\b\" -or $strADCompany -match \"\\b(Google)\\b\")\r\n                {\r\n                    $intFontSize = 8\r\n                    $strLine1 = \"COMPANY NAME Registered in Scotland number #######. Registered office address: ############ $nl\"\r\n                    $strLine2 = \"Company Name Is a subsidiary of Company Name\"\r\n                }\r\n                elseif ($strADCompany -match \"\\b(Amazon\\b\")\r\n                {\r\n                    $intFontSize = 8\r\n                    $strLine1 = \"COMPANY NAME Registered in Scotland number #######. Registered office address: ############ $nl\"\r\n                    $strLine2 = \"Company Name Is a subsidiary of Company Name\"\r\n                }\r\n            }\r\n            \"Australia\" \r\n            {\r\n                $intFontSize = 8\r\n                $strLine1 = \"COMPANY NAME Registered in Australia. Registered office address: ADDRESS$nl\"\r\n                $strLine2 = \"Company Name. Is a subsidiary of Company Name\"\r\n            }\r\n            \"Canada\" \r\n            {\r\n                $intFontSize = 8\r\n                $strLine1 = \"Registered in Canada. Registered office address: ADDRESS $nl\"\r\n                $strLine2 = \"Company Name Is a subsidiary of Company Name.\"\r\n            }\r\n            default {}\r\n        }\r\n\r\n        $objCountryDetails | Add-Member -MemberType NoteProperty -Name \"FontSize\" -Value $intFontSize\r\n        $objCountryDetails | Add-Member -MemberType NoteProperty -Name \"Line1\" -Value $strLine1\r\n        $objCountryDetails | Add-Member -MemberType NoteProperty -Name \"Line2\" -Value $strLine2\r\n    }\r\n    catch\r\n    {\r\n        $errItemName = $_.Exception.ItemName\r\n        Log-This -strLogLocation $strLogLocation -strErrorMessage \"$errItemName - $_\"\r\n    }\r\n\r\n    if ( $intFontSize -eq $null)\r\n    {\r\n        $objCountryDetails = $null\r\n    }\r\n    Return $objCountryDetails\r\n}\r\n\r\nfunction Add-Name\r\n{\r\n    [cmdletbinding()]\r\n    param(\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=0)]\r\n    [validatenotnullorempty()]\r\n    [string]$strLogLocation,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=1)]\r\n    [validatenotnullorempty()]\r\n    $objSelection,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=2)]\r\n    [validatenotnullorempty()]\r\n    [string]$strADDisplayName,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=3)]\r\n    [validatenotnullorempty()]\r\n    $objNameStyle\r\n    )\r\n\r\n    try\r\n    {\r\n        $objSelection.ParagraphFormat.SpaceAfter = 0\r\n        $objSelection.ParagraphFormat.SpaceBefore = 0\r\n        if ($objNameStyle.Size -ne $null)\r\n        {\r\n            $objSelection.Font.Size = $objNameStyle.Size\r\n        }\r\n        if ($objNameStyle.Bold -ne $null)\r\n        {\r\n            $objSelection.Font.Bold = $objNameStyle.Bold\r\n        }\r\n        if ($objNameStyle.Italic -ne $null)\r\n        {\r\n            $objSelection.Font.Italic = $objNameStyle.Italic\r\n        }\r\n        if ($objNameStyle.Color -ne $null)\r\n        {\r\n            $objSelection.Font.Color = $objNameStyle.Color\r\n        }\r\n        if ($objNameStyle.Name -ne $null)\r\n        {\r\n            $objSelection.Font.Name = $objNameStyle.Name\r\n        }\r\n        $objSelection.TypeText($strADDisplayName)\r\n        $objSelection.TypeParagraph()\r\n    }\r\n    catch\r\n    {\r\n        $errItemName = $_.Exception.ItemName\r\n        Log-This -strLogLocation $strLogLocation -strErrorMessage \"$errItemName - $_\"\r\n    }\r\n\r\n    Return $objSelection\r\n}\r\n\r\nfunction Add-Title\r\n{\r\n    [cmdletbinding()]\r\n    param(\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=0)]\r\n    [validatenotnullorempty()]\r\n    [string]$strLogLocation,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=1)]\r\n    [validatenotnullorempty()]\r\n    $objSelection,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=2)]\r\n    [validatenotnullorempty()]\r\n    [string]$strADTitle,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=3)]\r\n    [validatenotnullorempty()]\r\n    $objTitleStyle\r\n    )\r\n\r\n     try\r\n    {\r\n        if ($objTitleStyle.Size -ne $null)\r\n        {\r\n            $objSelection.Font.Size = $objTitleStyle.Size\r\n        }\r\n        if ($objTitleStyle.Bold -ne $null)\r\n        {\r\n            $objSelection.Font.Bold = $objTitleStyle.Bold\r\n        }\r\n        if ($objTitleStyle.Italic -ne $null)\r\n        {\r\n            $objSelection.Font.Italic = $objTitleStyle.Italic\r\n        }\r\n        if ($objTitleStyle.Color -ne $null)\r\n        {\r\n            $objSelection.Font.Color = $objTitleStyle.Color\r\n        }\r\n        if ($objTitleStyle.Name -ne $null)\r\n        {\r\n            $objSelection.Font.Name = $objTitleStyle.Name\r\n        }\r\n        $objSelection.TypeText($strADTitle)\r\n        $objSelection.TypeParagraph()\r\n    }\r\n    catch\r\n    {\r\n        $errItemName = $_.Exception.ItemName\r\n        Log-This -strLogLocation $strLogLocation -strErrorMessage \"$errItemName - $_\"\r\n    }\r\n\r\n    Return $objSelection\r\n}\r\n\r\nfunction Add-Tel\r\n{\r\n    [cmdletbinding()]\r\n    param(\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=0)]\r\n    [validatenotnullorempty()]\r\n    [string]$strLogLocation,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=1)]\r\n    [validatenotnullorempty()]\r\n    $objSelection,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=2)]\r\n    [validatenotnullorempty()]\r\n    [string]$strADTelePhoneNumber,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=3)]\r\n    [validatenotnullorempty()]\r\n    $objTelStyle\r\n    )\r\n\r\n     try\r\n    {\r\n        if ($objTelStyle.Size -ne $null)\r\n        {\r\n            $objSelection.Font.Size = $objTelStyle.Size\r\n        }\r\n        if ($objTelStyle.Bold -ne $null)\r\n        {\r\n            $objSelection.Font.Bold = $objTelStyle.Bold\r\n        }\r\n        if ($objTelStyle.Italic -ne $null)\r\n        {\r\n            $objSelection.Font.Italic = $objTelStyle.Italic\r\n        }\r\n        if ($objTelStyle.Color -ne $null)\r\n        {\r\n            $objSelection.Font.Color = $objTelStyle.Color\r\n        }\r\n        if ($objTelStyle.Name -ne $null)\r\n        {\r\n            $objSelection.Font.Name = $objTelStyle.Name\r\n        }\r\n        $objSelection.TypeText(\"Tel: $strADTelePhoneNumber\")\r\n        $objSelection.TypeParagraph()\r\n    }\r\n    catch\r\n    {\r\n        $errItemName = $_.Exception.ItemName\r\n        Log-This -strLogLocation $strLogLocation -strErrorMessage \"$errItemName - $_\"\r\n    }\r\n\r\n    Return $objSelection\r\n}\r\nfunction Add-Tel2\r\n{\r\n    [cmdletbinding()]\r\n    param(\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=0)]\r\n    [validatenotnullorempty()]\r\n    [string]$strLogLocation,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=1)]\r\n    [validatenotnullorempty()]\r\n    $objSelection,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=2)]\r\n    [validatenotnullorempty()]\r\n    [string]$strADTelePhoneNumber2,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=3)]\r\n    [validatenotnullorempty()]\r\n    $objTelStyle\r\n    )\r\n\r\n     try\r\n    {\r\n        if ($objTelStyle.Size -ne $null)\r\n        {\r\n            $objSelection.Font.Size = $objTelStyle.Size\r\n        }\r\n        if ($objTelStyle.Bold -ne $null)\r\n        {\r\n            $objSelection.Font.Bold = $objTelStyle.Bold\r\n        }\r\n        if ($objTelStyle.Italic -ne $null)\r\n        {\r\n            $objSelection.Font.Italic = $objTelStyle.Italic\r\n        }\r\n        if ($objTelStyle.Color -ne $null)\r\n        {\r\n            $objSelection.Font.Color = $objTelStyle.Color\r\n        }\r\n        if ($objTelStyle.Name -ne $null)\r\n        {\r\n            $objSelection.Font.Name = $objTelStyle.Name\r\n        }\r\n        $objSelection.TypeText(\"Tel: $strADTelePhoneNumber\")\r\n        $objSelection.TypeParagraph()\r\n    }\r\n    catch\r\n    {\r\n        $errItemName = $_.Exception.ItemName\r\n        Log-This -strLogLocation $strLogLocation -strErrorMessage \"$errItemName - $_\"\r\n    }\r\n\r\n    Return $objSelection\r\n}\r\n\r\nfunction Add-Mobile\r\n{\r\n    [cmdletbinding()]\r\n    param(\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=0)]\r\n    [validatenotnullorempty()]\r\n    [string]$strLogLocation,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=1)]\r\n    [validatenotnullorempty()]\r\n    $objSelection,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=2)]\r\n    [validatenotnullorempty()]\r\n    [string]$strADMobile,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=3)]\r\n    [validatenotnullorempty()]\r\n    $objMobileStyle\r\n    )\r\n\r\n     try\r\n    {\r\n        if ($objMobileStyle.Size -ne $null)\r\n        {\r\n            $objSelection.Font.Size = $objMobileStyle.Size\r\n        }\r\n        if ($objMobileStyle.Bold -ne $null)\r\n        {\r\n            $objSelection.Font.Bold = $objMobileStyle.Bold\r\n        }\r\n        if ($objMobileStyle.Italic -ne $null)\r\n        {\r\n            $objSelection.Font.Italic = $objMobileStyle.Italic\r\n        }\r\n        if ($objMobileStyle.Color -ne $null)\r\n        {\r\n            $objSelection.Font.Color = $objMobileStyle.Color\r\n        }\r\n        if ($objMobileStyle.Name -ne $null)\r\n        {\r\n            $objSelection.Font.Name = $objMobileStyle.Name\r\n        }\r\n        $objSelection.TypeText(\"Mob: $strADMobile\")\r\n        $objSelection.TypeParagraph()\r\n    }\r\n    catch\r\n    {\r\n        $errItemName = $_.Exception.ItemName\r\n        Log-This -strLogLocation $strLogLocation -strErrorMessage \"$errItemName - $_\"\r\n    }\r\n\r\n    Return $objSelection\r\n}\r\nfunction Add-Mobile2\r\n{\r\n    [cmdletbinding()]\r\n    param(\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=0)]\r\n    [validatenotnullorempty()]\r\n    [string]$strLogLocation,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=1)]\r\n    [validatenotnullorempty()]\r\n    $objSelection,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=2)]\r\n    [validatenotnullorempty()]\r\n    [string]$strADMobile2,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=3)]\r\n    [validatenotnullorempty()]\r\n    $objMobileStyle\r\n    )\r\n\r\n     try\r\n    {\r\n        if ($objMobileStyle.Size -ne $null)\r\n        {\r\n            $objSelection.Font.Size = $objMobileStyle.Size\r\n        }\r\n        if ($objMobileStyle.Bold -ne $null)\r\n        {\r\n            $objSelection.Font.Bold = $objMobileStyle.Bold\r\n        }\r\n        if ($objMobileStyle.Italic -ne $null)\r\n        {\r\n            $objSelection.Font.Italic = $objMobileStyle.Italic\r\n        }\r\n        if ($objMobileStyle.Color -ne $null)\r\n        {\r\n            $objSelection.Font.Color = $objMobileStyle.Color\r\n        }\r\n        if ($objMobileStyle.Name -ne $null)\r\n        {\r\n            $objSelection.Font.Name = $objMobileStyle.Name\r\n        }\r\n        $objSelection.TypeText(\"Mob: $strADMobile2\")\r\n        $objSelection.TypeParagraph()\r\n    }\r\n    catch\r\n    {\r\n        $errItemName = $_.Exception.ItemName\r\n        Log-This -strLogLocation $strLogLocation -strErrorMessage \"$errItemName - $_\"\r\n    }\r\n\r\n    Return $objSelection\r\n}\r\n\r\nfunction Add-Fax\r\n{\r\n    [cmdletbinding()]\r\n    param(\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=0)]\r\n    [validatenotnullorempty()]\r\n    [string]$strLogLocation,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=1)]\r\n    [validatenotnullorempty()]\r\n    $objSelection,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=2)]\r\n    [validatenotnullorempty()]\r\n    [string]$strADFax,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=3)]\r\n    [validatenotnullorempty()]\r\n    $objFaxStyle\r\n    )\r\n\r\n     try\r\n    {\r\n        if ($objFaxStyle.Size -ne $null)\r\n        {\r\n            $objSelection.Font.Size = $objFaxStyle.Size\r\n        }\r\n        if ($objFaxStyle.Bold -ne $null)\r\n        {\r\n            $objSelection.Font.Bold = $objFaxStyle.Bold\r\n        }\r\n        if ($objFaxStyle.Italic -ne $null)\r\n        {\r\n            $objSelection.Font.Italic = $objFaxStyle.Italic\r\n        }\r\n        if ($objFaxStyle.Color -ne $null)\r\n        {\r\n            $objSelection.Font.Color = $objFaxStyle.Color\r\n        }\r\n        if ($objFaxStyle.Name -ne $null)\r\n        {\r\n            $objSelection.Font.Name = $objFaxStyle.Name\r\n        }\r\n        $objSelection.TypeText(\"Fax: $strADFax\")\r\n        $objSelection.TypeParagraph()\r\n    }\r\n    catch\r\n    {\r\n        $errItemName = $_.Exception.ItemName\r\n        Log-This -strLogLocation $strLogLocation -strErrorMessage \"$errItemName - $_\"\r\n    }\r\n\r\n    Return $objSelection\r\n}\r\n\r\nfunction Add-CompanySpecific\r\n{\r\n    [cmdletbinding()]\r\n    param(\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=0)]\r\n    [validatenotnullorempty()]\r\n    [string]$strLogLocation,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=1)]\r\n    [validatenotnullorempty()]\r\n    $objSelection,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=2)]\r\n    [validatenotnullorempty()]\r\n    $objDocument,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=3)]\r\n    [validatenotnullorempty()]\r\n    $objCompanyInfo,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=4)]\r\n    [validatenotnullorempty()]\r\n    [int]$intPSVersion,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=5)]\r\n    $objBanner,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=5)]\r\n    $bolBanner\r\n    \r\n    )\r\n    try\r\n    {\r\n        ##$objLink = $objDocument.Hyperlinks.Add($objSelection,$objCompanyInfo.Hyperlink[1],$null,$null,$objCompanyInfo.Hyperlink[0])\r\n        if ($intPSVersion -eq 2)\r\n        {\r\n            $objRange = $objSelection.Range\r\n            $objDocument.Hyperlinks.Add($objRange, $objCompanyInfo.Hyperlink[1], $False, $False, $objCompanyInfo.Hyperlink[0]) \r\n            $objSelection.TypeParagraph()\r\n            $objSelection.InlineShapes.AddPicture($objCompanyInfo.Picture)\r\n            $objSelection.TypeParagraph()\r\n            if ($bolBanner -eq $true)\r\n            {\r\n                ##Email Signature addition as per ticket #29851\r\n                if ($objBanner.banners -ne $null -and $(get-date) -lt $objBanner.End_Date -and $(get-date) -gt $objBanner.Start_Date)\r\n                {\r\n                    $objSelection.InlineShapes.AddPicture($objBanner.File_Location)\r\n                    $objSelection.TypeParagraph()\r\n                }\r\n            }\r\n        }\r\n        else\r\n        {\r\n            $objRange = $objSelection.Range()\r\n            $objDocument.Hyperlinks.Add($objRange, $objCompanyInfo.Hyperlink[1], $False, $False, $objCompanyInfo.Hyperlink[0]) \r\n            $objSelection.TypeParagraph()\r\n            $objSelection.InlineShapes.AddPicture($objCompanyInfo.Picture)\r\n            $objSelection.TypeParagraph()\r\n            ##Email Signature addition as per ticket #29851\r\n            if ($bolBanner -eq $true)\r\n            {\r\n                if ($objBanner.banners -ne $null -and $(get-date) -lt $objBanner.End_Date -and $(get-date) -gt $objBanner.Start_Date)\r\n                {\r\n                    $objSelection.InlineShapes.AddPicture($objBanner.File_Location)\r\n                    $objSelection.TypeParagraph()\r\n                }\r\n            }\r\n        }\r\n    }\r\n    catch\r\n    {\r\n        $errItemName = $_.Exception.ItemName\r\n        Log-This -strLogLocation $strLogLocation -strErrorMessage \"$errItemName - $_\"\r\n        Log-This -strLogLocation $strLogLocation -strErrorMessage \"$intPSVersion\"\r\n    }\r\n    Return $objSelection\r\n}\r\n\r\nfunction Add-ARInfo\r\n{\r\n    [cmdletbinding()]\r\n    param(\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=0)]\r\n    [validatenotnullorempty()]\r\n    [string]$strLogLocation,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=1)]\r\n    [validatenotnullorempty()]\r\n    $objSelection,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=2)]\r\n    [validatenotnullorempty()]\r\n    $objArStyle\r\n    )\r\n    try\r\n    {\r\n        if ($objArStyle.Size -ne $null)\r\n        {\r\n            $objSelection.Font.Size = $objArStyle.Size\r\n        }\r\n        if ($objArStyle.Bold -ne $null)\r\n        {\r\n            $objSelection.Font.Bold = $objArStyle.Bold\r\n        }\r\n        if ($objArStyle.Italic -ne $null)\r\n        {\r\n            $objSelection.Font.Italic = $objArStyle.Italic\r\n        }\r\n        if ($objArStyle.Color -ne $null)\r\n        {\r\n            $objSelection.Font.Color = $objArStyle.Color\r\n        }\r\n        if ($objArStyle.Name -ne $null)\r\n        {\r\n            $objSelection.Font.Name = $objArStyle.Name\r\n        }\r\n        $objSelection.TypeText(\"Please remit all payments to: \")\r\n        $objSelection.TypeParagraph()\r\n        $objSelection.TypeText(\"**Company Name**\")\r\n        $objSelection.TypeParagraph()\r\n        $objSelection.TypeText(\"**Second Line**\")\r\n        $objSelection.TypeParagraph()\r\n        $objSelection.TypeText(\"PO BOX ******\")\r\n        $objSelection.TypeParagraph()\r\n        $objSelection.TypeText(\"City, State ZIP\")\r\n        $objSelection.TypeParagraph()\r\n    }\r\n    catch\r\n    {\r\n        $errItemName = $_.Exception.ItemName\r\n        Log-This -strLogLocation $strLogLocation -strErrorMessage \"$errItemName - $_\"\r\n    }\r\n    Return $objSelection\r\n}\r\n\r\nfunction Add-CountrySpecific\r\n{\r\n    [cmdletbinding()]\r\n    param(\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=0)]\r\n    [validatenotnullorempty()]\r\n    [string]$strLogLocation,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=1)]\r\n    [validatenotnullorempty()]\r\n    $objSelection,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=2)]\r\n    [validatenotnullorempty()]\r\n    $objCountryStyle,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=3)]\r\n    [validatenotnullorempty()]\r\n    $objCountryInfo\r\n    )\r\n    try\r\n    {\r\n        if ($objCountryStyle.Size -ne $null)\r\n        {\r\n            $objSelection.Font.Size = [Int]$objCountryStyle.Size\r\n        }\r\n        if ($objCountryStyle.Bold -ne $null)\r\n        {\r\n            $objSelection.Font.Bold = $objCountryStyle.Bold\r\n        }\r\n        if ($objCountryStyle.Italic -ne $null)\r\n        {\r\n            $objSelection.Font.Italic = $objCountryStyle.Italic\r\n        }\r\n        if ($objCountryStyle.Color -ne $null)\r\n        {\r\n            $objSelection.Font.Color = $objCountryStyle.Color\r\n        }\r\n        if ($objCountryStyle.Name -ne $null)\r\n        {\r\n            $objSelection.Font.Name = $objCountryStyle.Name\r\n        }\r\n        $objSelection.TypeText($objCountryInfo.Line1)\r\n        $objSelection.TypeText($objCountryInfo.Line2)\r\n        $objSelection.TypeParagraph()\r\n    }\r\n    catch\r\n    {\r\n        $errItemName = $_.Exception.ItemName\r\n        Log-This -strLogLocation $strLogLocation -strErrorMessage \"Company Object: $errItemName - $_\"\r\n        Log-This -strLogLocation $strLogLocation -strErrorMessage \"$($objSelection.Font.Size)\"\r\n        Log-This -strLogLocation $strLogLocation -strErrorMessage \"$($objCountryStyle.Size)\"\r\n    }\r\n    Return $objSelection\r\n}\r\n\r\nfunction Create-StyleObject\r\n{\r\n    [cmdletbinding()]\r\n    param(\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=0)]\r\n    [validatenotnullorempty()]\r\n    [string]$strLogLocation,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=1)]\r\n    [validatenotnullorempty()]\r\n    $intFontSize,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=2)]\r\n    [AllowNull()]\r\n    $intBold,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=3)]\r\n    [AllowNull()]\r\n    $intItalic,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=4)]\r\n    [AllowNull()]\r\n    $strColor,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=5)]\r\n    [AllowNull()]\r\n    $strName\r\n    )\r\n\r\n    $objStyleInfo = New-Object System.Object\r\n    try\r\n    {\r\n        $objStyleInfo | Add-Member -MemberType NoteProperty -Name \"Size\" -Value $intFontSize\r\n        $objStyleInfo | Add-Member -MemberType NoteProperty -Name \"Bold\" -Value $intBold\r\n        $objStyleInfo | Add-Member -MemberType NoteProperty -Name \"Italic\" -Value $intItalic\r\n        $objStyleInfo | Add-Member -MemberType NoteProperty -Name \"Color\" -Value $strColor\r\n        $objStyleInfo | Add-Member -MemberType NoteProperty -Name \"Name\" -Value $strName\r\n    }\r\n    catch\r\n    {\r\n        $errItemName = $_.Exception.ItemName\r\n        Log-This -strLogLocation $strLogLocation -strErrorMessage \"Style Object: $errItemName - $_\"\r\n    }\r\n\r\n    Return $objStyleInfo\r\n\r\n}\r\n\r\nfunction Remove-ComObject\r\n{\r\n    [cmdletbinding()]\r\n    param(\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=0)]\r\n    [validatenotnullorempty()]\r\n    [string]$strLogLocation,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=1)]\r\n    [validatenotnullorempty()]\r\n    $comMSWord\r\n    )\r\n\r\n    try\r\n    {\r\n    [System.Runtime.InteropServices.Marshal]::ReleaseComObject([System.__ComObject]$comMSWord) | Out-Null\r\n    [gc]::Collect()\r\n    [gc]::WaitForPendingFinalizers()\r\n    Remove-Variable comMSWord\r\n    }\r\n    catch\r\n    {\r\n        $errItemName = $_.Exception.ItemName\r\n        Log-This -strLogLocation $strLogLocation -strErrorMessage \"$errItemName - $_\"\r\n    }\r\n\r\n}\r\n\r\nfunction Create-InfoObject\r\n{\r\n[cmdletbinding()]\r\n    param(\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=0)]\r\n    [validatenotnullorempty()]\r\n    [string]$strLogLocation,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=1)]\r\n    [validatenotnullorempty()]\r\n    [string]$strADDisplayName,\r\n\r\n    [parameter(\r\n            Position=2)]\r\n    [validatenotnullorempty()]\r\n    [string]$strADTitle,\r\n\r\n    [parameter(\r\n            Position=3)]\r\n    $strADTelePhoneNumber,\r\n\r\n    [parameter(\r\n            Position=4)]\r\n    $strADTelePhoneNumber2,\r\n\r\n    [parameter(\r\n            Position=5)]\r\n    $strADMobile,\r\n\r\n    [parameter(\r\n            Position=6)]\r\n    $strADMobile2,\r\n\r\n    [parameter(\r\n            Position=7)]\r\n    $strADCompany,\r\n\r\n    [parameter(\r\n            Position=8)]\r\n    $strDepartment,\r\n\r\n    [parameter(\r\n            Position=9)]\r\n    $strFax,\r\n\r\n    [parameter(\r\n            Position=10)]\r\n    $strARCar,\r\n\r\n    [parameter(\r\n            Position=11)]\r\n    $strCountry,\r\n\r\n    [parameter(\r\n            Position=12)]\r\n    $strImage,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=13)]\r\n    [string]$strInfoLogLocation,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=14)]\r\n    [boolean]$Banner\r\n\r\n    )\r\n\r\n    $objInfo = New-Object System.Object\r\n    try\r\n    {\r\n        $objInfo | Add-Member -MemberType NoteProperty -Name \"DisplayName\" -Value $strADDisplayName\r\n        $objInfo | Add-Member -MemberType NoteProperty -Name \"Title\" -Value $strADTitle\r\n        $objInfo | Add-Member -MemberType NoteProperty -Name \"Tel1\" -Value $strADTelePhoneNumber.Value\r\n        $objInfo | Add-Member -MemberType NoteProperty -Name \"Tel2\" -Value $strADTelePhoneNumber2.Value\r\n        $objInfo | Add-Member -MemberType NoteProperty -Name \"Mob\" -Value $strADMobile.Value\r\n        $objInfo | Add-Member -MemberType NoteProperty -Name \"Mob2\" -Value $strADMobile2.Value\r\n        $objInfo | Add-Member -MemberType NoteProperty -Name \"Company\" -Value $strADCompany.Value\r\n        $objInfo | Add-Member -MemberType NoteProperty -Name \"Department\" -Value $strDepartment.Value\r\n        $objInfo | Add-Member -MemberType NoteProperty -Name \"Fax\" -Value $strFax.Value\r\n        $objInfo | Add-Member -MemberType NoteProperty -Name \"AR\" -Value $strARCar.Value\r\n        $objInfo | Add-Member -MemberType NoteProperty -Name \"Country\" -Value $strCountry.Value\r\n        $objInfo | Add-Member -MemberType NoteProperty -Name \"Image\" -Value $strImage\r\n        $objInfo | Add-Member -MemberType NoteProperty -Name \"Banner\" -Value $Banner\r\n    }\r\n    catch\r\n    {\r\n        $errItemName = $_.Exception.ItemName\r\n        Log-This -strLogLocation $strLogLocation -strErrorMessage \"$errItemName - $_\"\r\n    }\r\n\r\n    Return $objInfo\r\n}\r\n\r\nfunction Compare-Info\r\n{\r\n[cmdletbinding()]\r\n    param(\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=0)]\r\n    [validatenotnullorempty()]\r\n    [string]$strLogLocation,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=1)]\r\n    [validatenotnullorempty()]\r\n    $objInfo,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=2)]\r\n    [validatenotnullorempty()]\r\n    [string]$strInfoLogLocation\r\n\r\n    )\r\n\r\n    $resetSig = $null\r\n    $nl = [Environment]::NewLine\r\n    try\r\n    {\r\n        if (!$(Test-Path $($env:appdata + \"\\Email-SignatureScript\\data.csv\")))\r\n        {\r\n            $objInfo | Export-Csv $($env:appdata + \"\\Email-SignatureScript\\data.csv\")\r\n        }\r\n        $objOldInfo = Import-Csv $($env:appdata + \"\\Email-SignatureScript\\data.csv\")\r\n\r\n        $objOldInfo = Remove-NewLine -strLogLocation $strLogLocation -objOldInfo $objOldInfo\r\n        If ($objOldInfo.DisplayName -ne $objInfo.DisplayName)\r\n        {\r\n            $resetSig = $true\r\n            Log-This -strLogLocation $strLogLocation -strErrorMessage \"Name Change\"\r\n        }\r\n        If ($objOldInfo.Title -ne $objInfo.Title)\r\n        {\r\n            $resetSig = $true\r\n            Log-This -strLogLocation $strLogLocation -strErrorMessage \"Title Change\"\r\n        }\r\n        If ($objOldInfo.Tel1 -ne $objInfo.Tel1)\r\n        {\r\n            $resetSig = $true\r\n            Log-This -strLogLocation $strLogLocation -strErrorMessage \"Tel1 Change\"\r\n        }\r\n        If ($objOldInfo.Tel2 -ne $objInfo.Tel2)\r\n        {\r\n            $resetSig = $true\r\n            Log-This -strLogLocation $strLogLocation -strErrorMessage \"Tel2 Change\"\r\n        }\r\n        If ($objOldInfo.Mob -ne $objInfo.Mob)\r\n        {\r\n            $resetSig = $true\r\n            Log-This -strLogLocation $strLogLocation -strErrorMessage \"Mob Change\"\r\n        }\r\n        If ($objOldInfo.Mob2 -ne $objInfo.Mob2)\r\n        {\r\n            $resetSig = $true\r\n            Log-This -strLogLocation $strLogLocation -strErrorMessage \"Mob2 Change\"\r\n        }\r\n        If ($objOldInfo.Company -ne $objInfo.Company)\r\n        {\r\n            $resetSig = $true\r\n            Log-This -strLogLocation $strLogLocation -strErrorMessage \"Company Change\"\r\n        }\r\n        If ($objOldInfo.Department -ne $objInfo.Department)\r\n        {\r\n            $resetSig = $true\r\n            Log-This -strLogLocation $strLogLocation -strErrorMessage \"Department Change\"\r\n        }\r\n        If ($objOldInfo.Fax -ne $objInfo.Fax)\r\n        {\r\n            $resetSig = $true\r\n            Log-This -strLogLocation $strLogLocation -strErrorMessage \"Fax Change\"\r\n        }\r\n        If ($objOldInfo.AR -ne $objInfo.AR)\r\n        {\r\n            $resetSig = $true\r\n            Log-This -strLogLocation $strLogLocation -strErrorMessage \"AR Change\"\r\n        }\r\n        If ($objOldInfo.Country -ne $objInfo.Country)\r\n        {\r\n            $resetSig = $true\r\n            Log-This -strLogLocation $strLogLocation -strErrorMessage \"Country Change\"\r\n        }\r\n        If ($objOldInfo.Banner -ne $objInfo.Banner)\r\n        {\r\n            $resetSig = $true\r\n            Log-This -strLogLocation $strLogLocation -strErrorMessage \"Banner status change\"\r\n        }\r\n\r\n        ##I convert to unix time since epoch ehre because compare dates wasn't working right\r\n        if ($objOldInfo.Image -ne $null)\r\n            {\r\n            if ($objOldInfo.Image -like \"*\/*\")\r\n            {\r\n                $resetSig = $true\r\n                Log-This -strLogLocation $strLogLocation -strErrorMessage \"Image? Change\"\r\n            }\r\n            elseif ($objInfo.Image -gt $objOldInfo.Image)\r\n            #If ($([Math]::Floor([decimal](Get-Date($dtOldImageLastWrite) -uformat \"%s\"))) -lt $([Math]::Floor([decimal](Get-Date($objInfo.Image) -uformat \"%s\"))))\r\n            {\r\n                $resetSig = $true\r\n                Log-This -strLogLocation $strLogLocation -strErrorMessage \"Image2? Change\"\r\n            }\r\n        }\r\n        else\r\n        {\r\n            $resetSig = $true\r\n        }\r\n    }\r\n    catch\r\n    {\r\n        Log-This -strLogLocation $strLogLocation -strErrorMessage \"$errItemName - $_\"\r\n        $resetSig = $false\r\n    }\r\n    Return $resetSig\r\n}\r\n\r\nfunction Reset-InfoLog\r\n{\r\n[cmdletbinding()]\r\n    param(\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=0)]\r\n    [validatenotnullorempty()]\r\n    [string]$strLogLocation,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=1)]\r\n    [validatenotnullorempty()]\r\n    $objInfo,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=2)]\r\n    [validatenotnullorempty()]\r\n    [string]$strInfoLogLocation\r\n\r\n    )\r\n\r\n    try\r\n    {\r\n        if ($(test-path $strInfoLogLocation) -eq $true)\r\n        {\r\n            Rename-Item $strInfoLogLocation -NewName $($env:appdata + \"\\Email-SignatureScript\\$(Get-Date -UFormat \"%Y_%m_%d_%M\").csv\")\r\n        }\r\n        $objInfo | Export-Csv $($env:appdata + \"\\Email-SignatureScript\\data.csv\")\r\n    }\r\n    catch\r\n    {\r\n        Log-This -strLogLocation $strLogLocation -strErrorMessage \"$errItemName - $_\"\r\n    }\r\n}\r\n\r\nFunction Get-Banners\r\n{\r\n    [cmdletbinding()]\r\n    param(\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=0)]\r\n    [validatenotnullorempty()]\r\n    [string]$strLogLocation,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=1)]\r\n    [validatenotnullorempty()]\r\n    $objGroups\r\n    \r\n    )\r\n    $objBanners = New-Object System.Object\r\n    ##Define Banner group and info\r\n    try\r\n    {\r\n        foreach ($group in $objGroups)\r\n        {\r\n            ## This needs to be the Distinguished name of the AD group\r\n            if ($group -eq \"CN=,OU=,OU=,DC=,=com\" -and $(get-date) -lt $(Get-Date -Month 09 -Day 7 -Hour 17) -and $(get-date) -gt $(Get-Date -Month 08 -Day 01 -hour 0))\r\n            {\r\n                $objBanners | Add-Member -MemberType NoteProperty -Name \"Banners\" -Value \"Name\" -Force\r\n                $objBanners | Add-Member -MemberType NoteProperty -Name \"Start_Date\" -Value $(Get-Date -Month 08 -Day 01) -Force\r\n                $objBanners | Add-Member -MemberType NoteProperty -Name \"End_Date\" -Value $(Get-Date -Month 09 -Day 7 -Hour 17) -Force\r\n                $objBanners | Add-Member -MemberType NoteProperty -Name \"File_Location\" -Value \"$env:appdata\\Microsoft\\Stationery\\banner1.jpg\" -Force\r\n            }\r\n            if ($group -eq \"CN=,OU=,OU=,DC=,=com\" -and $(get-date) -lt $(Get-Date -Month 11 -Day 15 -Hour 17) -and $(get-date) -gt $(Get-Date -Month 10 -Day 01 -hour 0))\r\n            {\r\n                $objBanners | Add-Member -MemberType NoteProperty -Name \"Banners\" -Value \"Name2\" -Force\r\n                $objBanners | Add-Member -MemberType NoteProperty -Name \"Start_Date\" -Value $(Get-Date -Month 10 -Day 01) -Force\r\n                $objBanners | Add-Member -MemberType NoteProperty -Name \"End_Date\" -Value $(Get-Date -Month 11 -Day 15 -Hour 17) -Force\r\n                $objBanners | Add-Member -MemberType NoteProperty -Name \"File_Location\" -Value \"$env:appdata\\Microsoft\\Stationery\\banner2.jpg\" -Force\r\n            }\r\n        }\r\n    }\r\n    catch\r\n    {\r\n        $errItemName = $_.Exception.ItemName\r\n        Log-This -strLogLocation $strLogLocation -strErrorMessage \"$errItemName - $_\"\r\n    }\r\n    Return $objBanners\r\n}\r\n\r\nfunction Remove-NewLine\r\n{\r\n[cmdletbinding()]\r\n    param(\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=0)]\r\n    [validatenotnullorempty()]\r\n    [string]$strLogLocation,\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=1)]\r\n    [validatenotnullorempty()]\r\n    $objOldInfo\r\n    )\r\n\r\n    try\r\n    {\r\n        If ([string]::IsNullOrEmpty($objOldInfo.DisplayName))\r\n        {\r\n            $objOldInfo.DisplayName = $null\r\n        }\r\n        If ([string]::IsNullOrEmpty($objOldInfo.Title))\r\n        {\r\n            $objOldInfo.Title = $null\r\n        }\r\n        If ([string]::IsNullOrEmpty($objOldInfo.Tel1))\r\n        {\r\n            $objOldInfo.Tel1 = $null\r\n        }\r\n        If ([string]::IsNullOrEmpty($objOldInfo.Tel2))\r\n        {\r\n            $objOldInfo.Tel2 = $null\r\n        }\r\n        If ([string]::IsNullOrEmpty($objOldInfo.Mob))\r\n        {\r\n            $objOldInfo.Mob = $null\r\n        }\r\n        If ([string]::IsNullOrEmpty($objOldInfo.Mob2))\r\n        {\r\n            $objOldInfo.Mob2 = $null\r\n        }\r\n        If ([string]::IsNullOrEmpty($objOldInfo.Company))\r\n        {\r\n            $objOldInfo.Company = $null\r\n        }\r\n        If ([string]::IsNullOrEmpty($objOldInfo.Department))\r\n        {\r\n            $objOldInfo.Department = $null\r\n        }\r\n        If ([string]::IsNullOrEmpty($objOldInfo.Fax))\r\n        {\r\n            $objOldInfo.Fax = $null\r\n        }\r\n        If ([string]::IsNullOrEmpty($objOldInfo.AR))\r\n        {\r\n            $objOldInfo.AR = $null\r\n        }\r\n        If ([string]::IsNullOrEmpty($objOldInfo.Country))\r\n        {\r\n            $objOldInfo.Country = $null\r\n        }\r\n    }\r\n    catch\r\n    {\r\n        Log-This -strLogLocation $strLogLocation -strErrorMessage \"$errItemName - $_\"\r\n    }\r\n    Return $objOldInfo\r\n}\r\n\r\nfunction Set-RegistryKeys\r\n{\r\n    [cmdletbinding()]\r\n    param(\r\n\r\n    [parameter(Mandatory=$true,\r\n            Position=0)]\r\n    [validatenotnullorempty()]\r\n    [string]$strSignatureName\r\n    )\r\n\r\n    #Office 2010 \r\n    If (Test-Path HKCU:'\\Software\\Microsoft\\Office\\14.0')\r\n    { \r\n        if ($(Get-ItemProperty HKCU:'\\Software\\Microsoft\\Office\\14.0\\Common\\MailSettings' -Name 'NewSignature' -ErrorAction SilentlyContinue) -ne $strSignatureName)\r\n        {\r\n            Set-ItemProperty HKCU:'\\Software\\Microsoft\\Office\\14.0\\Common\\MailSettings' -Name 'NewSignature' -Value $strSignatureName -Force  | Out-Null\r\n        }\r\n        else\r\n        {\r\n            New-ItemProperty HKCU:'\\Software\\Microsoft\\Office\\14.0\\Common\\MailSettings' -Name 'NewSignature' -Value $strSignatureName -PropertyType 'String' -Force  | Out-Null\r\n        }\r\n        if ($(Get-ItemProperty HKCU:'\\Software\\Microsoft\\Office\\14.0\\Common\\MailSettings' -Name 'ReplySignature' -ErrorAction SilentlyContinue) -ne $strSignatureName)\r\n        {\r\n            Set-ItemProperty HKCU:'\\Software\\Microsoft\\Office\\14.0\\Common\\MailSettings' -Name 'ReplySignature' -Value $strSignatureName -Force  | Out-Null\r\n        }\r\n        else\r\n        {\r\n            New-ItemProperty HKCU:'\\Software\\Microsoft\\Office\\14.0\\Common\\MailSettings' -Name 'NewSignature' -Value $strSignatureName -PropertyType 'String' -Force  | Out-Null\r\n        }\r\n    } \r\n \r\n    #Office 2013 signature \r\n \r\n    If (Test-Path HKCU:'\\Software\\Microsoft\\Office\\15.0')\r\n    { \r\n        if ($(Get-ItemProperty HKCU:'\\Software\\Microsoft\\Office\\15.0\\Common\\MailSettings' -Name 'NewSignature' -ErrorAction SilentlyContinue) -ne $strSignatureName)\r\n        {\r\n            New-ItemProperty HKCU:'\\Software\\Microsoft\\Office\\15.0\\Common\\MailSettings' -Name 'NewSignature' -Value $strSignatureName -PropertyType 'String' -Force  | Out-Null\r\n        }\r\n        else\r\n        {\r\n            Set-ItemProperty HKCU:'\\Software\\Microsoft\\Office\\15.0\\Common\\MailSettings' -Name 'NewSignature' -Value $strSignatureName | Out-Null\r\n        }\r\n        if ($(Get-ItemProperty HKCU:'\\Software\\Microsoft\\Office\\15.0\\Common\\MailSettings' -Name 'ReplySignature' -ErrorAction SilentlyContinue) -ne $strSignatureName)\r\n        {\r\n            Set-ItemProperty HKCU:'\\Software\\Microsoft\\Office\\15.0\\Common\\MailSettings' -Name 'ReplySignature' -Value $strSignatureName -Force  | Out-Null\r\n        }\r\n        else\r\n        {\r\n            New-ItemProperty HKCU:'\\Software\\Microsoft\\Office\\15.0\\Common\\MailSettings' -Name 'ReplySignature' -Value $strSignatureName -PropertyType 'String' -Force  | Out-Null\r\n        }\r\n    }\r\n\r\n    #Office 2016 signature \r\n    If (Test-Path HKCU:'\\Software\\Microsoft\\Office\\16.0')\r\n    {\r\n        if ($(Get-ItemProperty HKCU:'\\Software\\Microsoft\\Office\\16.0\\Common\\MailSettings' -Name 'NewSignature' -ErrorAction SilentlyContinue) -ne $strSignatureName)\r\n        {\r\n            Set-ItemProperty HKCU:'\\Software\\Microsoft\\Office\\16.0\\Common\\MailSettings' -Name 'NewSignature' -Value $strSignatureName  -Force  | Out-Null\r\n        }\r\n        else\r\n        {\r\n            New-ItemProperty HKCU:'\\Software\\Microsoft\\Office\\16.0\\Common\\MailSettings' -Name 'NewSignature' -Value $strSignatureName -PropertyType 'String' -Force  | Out-Null\r\n        }\r\n        if ($(Get-ItemProperty HKCU:'\\Software\\Microsoft\\Office\\16.0\\Common\\MailSettings' -Name 'ReplySignature' -ErrorAction SilentlyContinue) -ne $strSignatureName)\r\n        {\r\n            Set-ItemProperty HKCU:'\\Software\\Microsoft\\Office\\16.0\\Common\\MailSettings' -Name 'ReplySignature' -Value $strSignatureName -Force  | Out-Null\r\n        }\r\n        else\r\n        {\r\n            New-ItemProperty HKCU:'\\Software\\Microsoft\\Office\\16.0\\Common\\MailSettings' -Name 'ReplySignature' -Value $strSignatureName -PropertyType 'String' -Force  | Out-Null\r\n        }\r\n    }\r\n}\r\n\r\n##This will prevent the script from running if the c:\\windows\\NoAutoEmailSig.dat file exists or if it exists in the appdata folder\r\n##The idea for this is we can create the file if there are issues and use the old script to buy us time to troubleshoot.\r\nif ($(Test-Path C:\\Windows\\NoAutoEmailSig.dat) -eq $true -or $(Test-Path \"$env:APPDATA\\Email-SignatureScript\\NoAutoEmailSig.dat\") -eq $true)\r\n{\r\n    ##Populate the string values below with your stuff\r\n    if ($(test-path $(\"\\\\SERVERNAME\\$env:COMPUTERNAME.txt\")) -eq $false -and $(Test-Connection -Count 1 -ComputerName \"SERVERNAME\" -ErrorAction SilentlyContinue))\r\n    {\r\n        New-Item -Path $(\"\\\\SERVERNAME\\$env:COMPUTERNAME.txt\") -ItemType file | Out-Null\r\n    }\r\n    exit\r\n}\r\nelse\r\n{\r\n    if ($(test-path $(\"\\\\SERVERNAME\\$env:COMPUTERNAME.txt\")) -eq $true -and $(Test-Connection -Count 1 -ComputerName \"Servername\" -ErrorAction SilentlyContinue))\r\n    {\r\n        gci \"\\\\SERVERNAME\\$env:COMPUTERNAME.txt\" | Remove-Item\r\n    }\r\n}\r\n\r\n\r\n##I see no reason to run this on a server. I will do wmi fitlering on GPO also\r\nif ($(Get-WmiObject -class Win32_OperatingSystem | select -expandProperty Caption | Out-String) -like \"*Server*\")\r\n{\r\n    exit\r\n}\r\n\r\n#Need connection to network for logging to work properly\r\nif (!$(Test-Connection -Count 1 -ComputerName \"SERVERNAME\" -ErrorAction SilentlyContinue))\r\n{\r\n    exit\r\n}\r\n\r\n##When adding picture Powershell 2.0 requires $objDocument.Range vs 5.0 which needs $objDocument.Range()\r\n$intPSVersion = $PSVersionTable.PSVersion.Major\r\nif ($PSVersionTable.PSVersion.Major -eq 2)\r\n{\r\n    $intPSVersion = 2\r\n}\r\n\r\n##This will force the script to run in full if the file %appdata\\Email-SignatureScript\\ForceUpdate.dat exists\r\nif ($(Test-Path \"$env:APPDATA\\Email-SignatureScript\\ForceUpdate.dat\") -eq $true)\r\n{\r\n    Remove-Item \"$env:APPDATA\\Email-SignatureScript\\ForceUpdate.dat\" -force\r\n    Remove-Item \"$env:APPDATA\\Microsoft\\Signatures\" -Recurse -force\r\n}\r\n\r\n##New line character for country info\r\n$nl = [System.Environment]::NewLine\r\n\r\nCreate-Log -strComputerName $env:COMPUTERNAME\r\n\r\n##Set Log Path Variable\r\n$strLogLocation = Get-LogLocation -strComputerName $env:COMPUTERNAME\r\n\r\nLog-This -strLogLocation $strLogLocation -strErrorMessage \"Script Trigggered\"\r\n\r\n#Environment variables\r\n$strSignatureName = \"Reddit Signature v1\"\r\n$strAppData=(Get-Item env:appdata).value \r\n$strSigPath = '\\Microsoft\\Signatures'\r\n$strLocalSignaturePath = $strAppData+$strSigPath\r\n\r\n##Create Sig Folder\r\nIf (!(Test-Path -path $strLocalSignaturePath))\r\n{ \r\n    New-Item $strLocalSignaturePath -Type Directory | Out-Null\r\n} \r\n\r\n\r\n##Get AD Info\r\n$strUserName = $env:USERNAME\r\n$strFilter = \"(&amp;(objectCategory=User)(samAccountName=$strUserName))\" \r\n$objSearcher = New-Object System.DirectoryServices.DirectorySearcher \r\n$objSearcher.Filter = $strFilter \r\n$objADUserPath = $objSearcher.FindOne()\r\nif ($objADUserPath -ne $null)\r\n{\r\n    $objADUser = $objADUserPath.GetDirectoryEntry() \r\n    $strADDisplayName = $objADUser.DisplayName\r\n    $strADTitle = $objADUser.title \r\n    $strADTelePhoneNumber = $objADUser.TelephoneNumber\r\n    $strADTelePhoneNumber2 = $objADUser.extensionAttribute1 \r\n    $strADMobile = $objADUser.mobile\r\n    $strADMobile2 = $objADUser.extensionAttribute2\r\n    $strADCompany = $objADUser.company\r\n    $strDepartment = $objADUser.Department\r\n    $strFax = $objADUser.facsimileTelephoneNumber\r\n    $strARCar = $objADUser.extensionAttribute10\r\n    $strCountry = $objADUser.co\r\n    $objMemberOf = $objADUser.memberOf\r\n}\r\n\r\n#Get banner info and determine if one is needed\r\n$objBanner = Get-Banners -strLogLocation $strLogLocation -objGroups $objMemberOf\r\nif ($objBanner.banners -ne $null -and $(get-date) -lt $objBanner.End_Date -and $(get-date) -gt $objBanner.Start_Date)\r\n{\r\n    $bolBanner = $true\r\n}\r\nelse\r\n{\r\n    $bolBanner = $false\r\n}\r\n\r\n##Get Company specific info\r\n$objCompanyInfo = Set-CompanyInfo -strLogLocation $strLogLocation -strADCompany $strADCompany\r\n$strSignatureName = $objCompanyInfo.Signame\r\n\r\n##FOR TESTING ONLY\r\n##$strCountry = \"United Kingdom\"\r\n##$strARCar = \"AR\"\r\n\r\n##Timestamp and unix timestamp for the logo (This is killing me...)\r\n$dtLocalLogoTimeStamp = $(get-date $([datetime]$(gci $objCompanyInfo.Picture | select -ExpandProperty LastWriteTime)))\r\n$strTimeSinceEpoch = $(New-TimeSpan -Start ('01\/01\/1970') -end $dtLocalLogoTimeStamp).Days\r\n\r\n##Compare new data and previous data to determine if script needs to be run\r\n$strInfoLogLocation = $($($env:appdata + \"\\Email-SignatureScript\\data.csv\"))\r\n$objInfo = Create-InfoObject -strLogLocation $strLogLocation -strADDisplayName $strADDisplayName -strADTitle $strADTitle -strADTelePhoneNumber $strADTelePhoneNumber -strADTelePhoneNumber2 $strADTelePhoneNumber2 -strADMobile $strADMobile -strADMobile2 $strADMobile2 -strADCompany $strADCompany -strDepartment $strDepartment -strFax $strFax -strARCar $strARCar -strCountry $strCountry -strImage $strTimeSinceEpoch -strInfoLogLocation $strInfoLogLocation -Banner $bolBanner\r\n$strSigReset = Compare-Info -strLogLocation $strLogLocation -objInfo $objInfo -strInfoLogLocation $strInfoLogLocation\r\nif ($strSigReset)\r\n{\r\n    Reset-InfoLog -strLogLocation $strLogLocation -objInfo $objInfo -strInfoLogLocation $strInfoLogLocation\r\n}\r\nelseif ( $(gci -path $($strLocalSignaturePath + \"\\\")) -eq $null)\r\n{\r\n    Reset-InfoLog -strLogLocation $strLogLocation -objInfo $objInfo -strInfoLogLocation $strInfoLogLocation\r\n}\r\nelse\r\n{\r\n    Log-This -strLogLocation $strLogLocation -strErrorMessage \"Completed - No need to run\"\r\n    Set-RegistryKeys -strSignatureName $strSignatureName | Out-Null\r\n    break\r\n}\r\n\r\n##Get Country specific info\r\n$objCountryInfo = Set-CountryInfo -strLogLocation $strLogLocation -strCountry $strCountry -strADCompany $strADCompany\r\n\r\n##Create com object and set spacing\r\n$arrWordBefore = Get-Process -Name \"WINWORD\" -ErrorAction SilentlyContinue\r\n$comMSWord = New-Object -ComObject word.application\r\n$arrWordAfter = Get-Process -Name \"WINWORD\"\r\nif ($arrWordBefore -ne $null)\r\n{\r\n    $objWord = Compare-Object $arrWordBefore $arrWordAfter | select -ExpandProperty InputObject \r\n}\r\nelse\r\n{\r\n    $objWord = $arrWordAfter\r\n}\r\n$comMSWord.Visible = $false\r\n$objDocument = $comMSWord.Documents.Add()\r\n$objDocument.Paragraphs.SpaceAfter = 0\r\n$objDocument.Paragraphs.SpaceAfter = 0\r\n$objSelection = $comMSWord.Selection \r\n\r\n##Add Name to document\r\n$objNameStyle = Create-StyleObject -strLogLocation $strLogLocation -intFontSize 11 -intBold 1 -intItalic $null -strColor $null -strName \"Calibri\"\r\n$objSelection = Add-Name -strLogLocation $strLogLocation -objSelection $objSelection -strADDisplayName $strADDisplayName -objNameStyle $objNameStyle\r\nRemove-Variable objNameStyle\r\n\r\n##Add Title to Document\r\n$objTitleStyle = Create-StyleObject -strLogLocation $strLogLocation -intFontSize 11 -intBold 0 -intItalic $null -strColor $null -strName \"Calibri\"\r\n$objSelection = Add-Title -strLogLocation $strLogLocation -objSelection $objSelection -strADTitle $strADTitle -objTitleStyle $objTitleStyle\r\nRemove-Variable objTitleStyle\r\n\r\n##Add Telephone if it exists\r\nif ( $strADTelePhoneNumber -ne $null)\r\n{\r\n    $objtelStyle = Create-StyleObject -strLogLocation $strLogLocation -intFontSize 11 -intBold 0 -intItalic $null -strColor $null -strName \"Calibri\"\r\n    $objSelection = Add-Tel -strLogLocation $strLogLocation -objSelection $objSelection -strADTelePhoneNumber $strADTelePhoneNumber -objTelStyle $objtelStyle\r\n    Remove-Variable objtelStyle\r\n}\r\n\r\n##Add Telephone2 if it exists\r\nif ( $strADTelePhoneNumber2 -ne $null)\r\n{\r\n    $objtelStyle = Create-StyleObject -strLogLocation $strLogLocation -intFontSize 11 -intBold 0 -intItalic $null -strColor $null -strName \"Calibri\"\r\n    $objSelection = Add-Tel -strLogLocation $strLogLocation -objSelection $objSelection -strADTelePhoneNumber $strADTelePhoneNumber2 -objTelStyle $objtelStyle\r\n    Remove-Variable objtelStyle\r\n}\r\n\r\n##Add Mobile if it exists\r\nif ( $strADMobile -ne $null)\r\n{\r\n    $objMobileStyle = Create-StyleObject -strLogLocation $strLogLocation -intFontSize 11 -intBold 0 -intItalic $null -strColor $null -strName \"Calibri\"\r\n    $objSelection = Add-Mobile -strLogLocation $strLogLocation -objSelection $objSelection -strADMobile $strADMobile -objMobileStyle $objMobileStyle\r\n    Remove-Variable objMobileStyle\r\n}\r\n\r\n##Add Mobile2 if it exists\r\nif ( $strADMobile2 -ne $null)\r\n{\r\n    $objMobileStyle = Create-StyleObject -strLogLocation $strLogLocation -intFontSize 11 -intBold 0 -intItalic $null -strColor $null -strName \"Calibri\"\r\n    $objSelection = Add-Mobile2 -strLogLocation $strLogLocation -objSelection $objSelection -strADMobile $strADMobile2 -objMobileStyle $objMobileStyle\r\n    Remove-Variable objMobileStyle\r\n}\r\n\r\n##Add Fax if it exists\r\nif ( $strFax -ne $null)\r\n{\r\n    $objFaxStyle = Create-StyleObject -strLogLocation $strLogLocation -intFontSize 11 -intBold 0 -intItalic $null -strColor $null -strName \"Calibri\"\r\n    $objSelection = Add-Fax -strLogLocation $strLogLocation -objSelection $objSelection -strADFax $strFax -objFaxStyle $objFaxStyle\r\n    Remove-Variable objFaxStyle\r\n}\r\n\r\n##Add Company specific data\r\n$objSelection = Add-CompanySpecific -strLogLocation $strLogLocation -objSelection $objSelection -objDocument $objDocument -objCompanyInfo $objCompanyInfo -intPSVersion $intPSVersion -objBanner $objBanner -bolBanner $bolBanner\r\n\r\n##Add AR info if needed\r\nif ( $strARCar -ne $null)\r\n{\r\n    $objARStyle = Create-StyleObject -strLogLocation $strLogLocation -intFontSize 8 -intBold 0 -intItalic $null -strColor $null -strName \"Calibri\"\r\n    $objSelection = Add-ARInfo -strLogLocation $strLogLocation -objSelection $objSelection[2] -objArStyle $objARStyle\r\n    Remove-Variable objARStyle\r\n}\r\n\r\n##Add country specific info if needed\r\nif ( $objCountryInfo -ne $null)\r\n{\r\n    if ($strARCar -ne $null)\r\n    {\r\n        $objCountryStyle = Create-StyleObject -strLogLocation $strLogLocation -intFontSize 8 -intBold 0 -intItalic $null -strColor $null -strName \"Calibri\"\r\n        $objSelection = Add-CountrySpecific -strLogLocation $strLogLocation -objSelection $objSelection -objCountryStyle $objCountryStyle -objCountryInfo $objCountryInfo\r\n        Remove-Variable objCountryStyle\r\n    }\r\n    else\r\n    {\r\n        $objCountryStyle = Create-StyleObject -strLogLocation $strLogLocation -intFontSize 8 -intBold 0 -intItalic $null -strColor $null -strName \"Calibri\"\r\n        $objSelection = Add-CountrySpecific -strLogLocation $strLogLocation -objSelection $objSelection[2] -objCountryStyle $objCountryStyle -objCountryInfo $objCountryInfo\r\n        Remove-Variable objCountryStyle\r\n    }\r\n}\r\n\r\nif ($strSigReset)\r\n{\r\n    $objSignatureFiles = gci $strLocalSignaturePath | select -ExpandProperty FullName\r\n    foreach ($strFile in $objSignatureFiles)\r\n    {\r\n        Remove-Item $strFile -force -Recurse\r\n    }\r\n}\r\n\r\n\r\n\r\n#Save HTML\r\ntry\r\n{\r\n    $refSaveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], \"wdFormatHTML\"); \r\n    $refPath = \"$strLocalSignaturePath\\$strSignatureName.htm\"\r\n    $comMSWord.ActiveDocument.SaveAs([ref][system.object]$refPath, [ref]$refSaveFormat)\r\n}\r\ncatch\r\n{\r\n    Log-This -strLogLocation $strLogLocation -strErrorMessage $_\r\n    Log-This -strLogLocation $strLogLocation -strErrorMessage $refPath\r\n    Log-This -strLogLocation $strLogLocation -strErrorMessage $refSaveFormat\r\n}\r\n     \r\n#Save RTF\r\ntry\r\n{\r\n    $refSaveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], \"wdFormatRTF\"); \r\n    $refPath = \"$strLocalSignaturePath\\$strSignatureName.rtf\"\r\n    $comMSWord.ActiveDocument.SaveAs([ref][system.object]$refPath, [ref]$refSaveFormat)\r\n}\r\ncatch\r\n{\r\n    Log-This -strLogLocation $strLogLocation -strErrorMessage $_\r\n    Log-This -strLogLocation $strLogLocation -strErrorMessage $refPath\r\n    Log-This -strLogLocation $strLogLocation -strErrorMessage $refSaveFormat\r\n}\r\n     \r\n#Save TXT\r\ntry\r\n{\r\n    $refSaveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], \"wdFormatText\"); \r\n    $refPath = \"$strLocalSignaturePath\\$strSignatureName.txt\"\r\n    $comMSWord.ActiveDocument.SaveAs([ref][system.object]$refPath, [ref]$refSaveFormat)\r\n    $comMSWord.ActiveDocument.Close()\r\n    $comMSWord.Quit()\r\n    [System.Runtime.Interopservices.Marshal]::ReleaseComObject($comMSWord)\r\n}\r\ncatch\r\n{\r\n    Log-This -strLogLocation $strLogLocation -strErrorMessage $_\r\n    Log-This -strLogLocation $strLogLocation -strErrorMessage $refPath\r\n    Log-This -strLogLocation $strLogLocation -strErrorMessage $refSaveFormat\r\n}\r\n\r\nStart-Sleep -Seconds 5\r\n\r\nSet-RegistryKeys -strSignatureName $strSignatureName | Out-Null\r\n\r\nLog-This -strLogLocation $strLogLocation -strErrorMessage \"Completed - $(get-date)\"\r\nif ($(Get-Process -Id $objWord.ID -ErrorAction SilentlyContinue) -ne $null)\r\n{\r\n    Stop-Process $objWord -Force\r\n}<\/code><\/pre>\n\n\n\n<p>Script 3<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/raymix\/PowerShell-Outlook-Signatures\">https:\/\/github.com\/raymix\/PowerShell-Outlook-Signatures<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Script 1 Script 2 Script 3 https:\/\/github.com\/raymix\/PowerShell-Outlook-Signatures<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[2331,2899,2900,1261,576,2898],"class_list":["post-4012","post","type-post","status-publish","format-standard","hentry","category-research","tag-deploy","tag-mail","tag-mail-merge","tag-merge","tag-powershell","tag-signature"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/4012","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/comments?post=4012"}],"version-history":[{"count":3,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/4012\/revisions"}],"predecessor-version":[{"id":7099,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/4012\/revisions\/7099"}],"wp:attachment":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/media?parent=4012"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/categories?post=4012"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/tags?post=4012"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}