Automate email signature

This commit is contained in:
AdminDroid 2025-01-21 11:25:58 +05:30
parent 0c43a1f6fd
commit d854d238b0

View File

@ -1,6 +1,6 @@
<#----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- <#-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Name: Automate Email Signature Setup in Outlook Using PowerShell Name: Automate Email Signature Setup in Outlook Using PowerShell
Version: 1.0 Version: 2.0
Website: o365reports.com Website: o365reports.com
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
@ -16,9 +16,16 @@ Script Highlights:
8. Supports certificate-based authentication (CBA) too. 8. Supports certificate-based authentication (CBA) too.
For detailed script execution: https://o365reports.com/2024/07/10/automate-email-signature-setup-in-outlook-using-powershell/ For detailed script execution: https://o365reports.com/2024/07/10/automate-email-signature-setup-in-outlook-using-powershell/
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------#>
#------------------------------------------------------------------------Block for passing params------------------------------------------------------------------------------------------
Change Log:
~~~~~~~~~~~
v1.0 (July 10, 2024)- Script created
V2.0 (Jan 18, 2025)- Error handling added to enabling PostponeRoamingSignatureUntilLater param.
------------------------------------------------------------------------------------------------------------#>
#Block for passing params
[CmdletBinding(DefaultParameterSetName = 'NoParams')] [CmdletBinding(DefaultParameterSetName = 'NoParams')]
param param
@ -67,15 +74,15 @@ if ($UserPrincipalName -ne "" -and $Password -ne "")
{ {
$SecurePassword = ConvertTo-SecureString -String $Password -AsPlainText -Force $SecurePassword = ConvertTo-SecureString -String $Password -AsPlainText -Force
$UserCredential = New-Object System.Management.Automation.PSCredential ($UserPrincipalName,$SecurePassword) $UserCredential = New-Object System.Management.Automation.PSCredential ($UserPrincipalName,$SecurePassword)
Connect-ExchangeOnline -Credential $UserCredential Connect-ExchangeOnline -Credential $UserCredential -ShowBanner:$false
} }
elseif ($Organization -ne "" -and $ClientId -ne "" -and $CertificateThumbprint -ne "") elseif ($Organization -ne "" -and $ClientId -ne "" -and $CertificateThumbprint -ne "")
{ {
Connect-ExchangeOnline -AppId $ClientId -CertificateThumbprint $CertificateThumbprint -Organization $Organization Connect-ExchangeOnline -AppId $ClientId -CertificateThumbprint $CertificateThumbprint -Organization $Organization -ShowBanner:$false
} }
elseif (-not $TaskScheduler) elseif (-not $TaskScheduler)
{ {
Connect-ExchangeOnline Connect-ExchangeOnline -ShowBanner:$false
} }
else else
{ {
@ -112,9 +119,17 @@ if ((-not (Get-OrganizationConfig).PostponeRoamingSignaturesUntilLater) -and (-n
if ($Enable_PostponeRoamingSignatureUntilLater -or $UserConfirmation -eq 1) if ($Enable_PostponeRoamingSignatureUntilLater -or $UserConfirmation -eq 1)
{ {
Set-OrganizationConfig -PostponeRoamingSignaturesUntilLater $true Set-OrganizationConfig -PostponeRoamingSignaturesUntilLater $true
if($?)
{
Write-Host "`n`PostponeRoamingSignatureUntilLater parameter enabled" -ForegroundColor Green Write-Host "`n`PostponeRoamingSignatureUntilLater parameter enabled" -ForegroundColor Green
break; break;
} }
else
{
Write-Host "Error occurred. Unable to enable PostPoneRoamingSignaturesUntilLater.Please try again" -ForegroundColor Red
Exit;
}
}
elseif ($UserConfirmation -eq 2) elseif ($UserConfirmation -eq 2)
{ {
Write-Host '`n`Without Enabling it, Signature can be added but not deployed to Users MailBox' -ForegroundColor Yellow Write-Host '`n`Without Enabling it, Signature can be added but not deployed to Users MailBox' -ForegroundColor Yellow