Repository: microsoft/CSS-Exchange
File: M365/MDO/ResendFailedMail.ps1 (PowerShell)

Code before:
.PARAMETER ShowDetailedPolicies
    In addition to the policy applied, show any policy details that are set to True, On, or not blank.
.PARAMETER SkipConnectionCheck
    Skips connection check for Graph and Exchange Online.
.PARAMETER SkipVersionCheck
    Skips the version check of the script.
.PARAMETER ScriptUpdateOnly
    Just updates script version to latest one.

.EXAMPLE
	.\ResendFailedMail.ps1
	To resend all Failed email from the past day.

.EXAMPLE
	.\ResendFailedMail.ps1 -Sender gary@contoso.com -Recipient ahmad@fabrikam.com -Days 7
	To resend Failed email from specific sender, recipient, and specified number of days.

.EXAMPLE
	.\ResendFailedMail.ps1 -Force -Sender gary@contsoso.com -Days 5
	To resend Failed email from a specific sender for the past 5 days without a confirmation prompt.
#>

[CmdletBinding(DefaultParameterSetName = 'ResendCopyFailed', SupportsShouldProcess = $true, ConfirmImpact = 'High')]
param(
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailed")]
    [string[]]$Sender,
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailed")]
    [string[]]$Subject,
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailed")]
    [string[]]$Recipient,
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailed")]
    [string[]]$MessageId,
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailed")]
    [switch]$IncludeDuplicates,
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailed")]
    [switch]$Force,
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailed")]
    [int]$Days = 1,
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailed")]
    [switch]$SkipConnectionCheck,
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailed")]
    [switch]$SkipVersionCheck,
    [Parameter(Mandatory = $true, ParameterSetName = "ScriptUpdateOnly")]
    [switch]$ScriptUpdateOnly
)

. $PSScriptRoot\..\..\Shared\ScriptUpdateFunctions\Test-ScriptVersion.ps1
. $PSScriptRoot\..\..\Shared\LoggerFunctions.ps1
. $PSScriptRoot\..\..\Shared\OutputOverrides\Write-Host.ps1
. $PSScriptRoot\..\..\Shared\OutputOverrides\Write-Progress.ps1
. $PSScriptRoot\..\..\Shared\OutputOverrides\Write-Verbose.ps1

Review comment (suggestion):
Avoid using an Automatic variable name as a parameter: 

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-7.4

Please change this to something else. 

Code after:
    Skips connection check for Graph and Exchange Online.
.PARAMETER SkipVersionCheck
    Skips the version check of the script.
.PARAMETER ScriptUpdateOnly
    Just updates script version to latest one.

.EXAMPLE
	.\ResendFailedMail.ps1
	To resend all Failed email from the past day.

.EXAMPLE
	.\ResendFailedMail.ps1 -SenderAddress gary@contoso.com -RecipientAddress  ahmad@fabrikam.com -Days 7
	To resend Failed email from specific sender, recipient, and specified number of days.

.EXAMPLE
	.\ResendFailedMail.ps1 -Force -SenderAddress gary@contsoso.com -Days 5
	To resend Failed email from a specific sender for the past 5 days without a confirmation prompt.
#>

[CmdletBinding(DefaultParameterSetName = 'ResendCopyFailed', SupportsShouldProcess = $true, ConfirmImpact = 'High')]
param(
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailed")]
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailedDays")]
    [string[]]$SenderAddress,
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailed")]
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailedDays")]
    [string[]]$Subject,
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailed")]
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailedDays")]
    [string[]]$RecipientAddress ,
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailed")]
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailedDays")]
    [string[]]$MessageId,
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailed")]
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailedDays")]
    [switch]$IncludeDuplicates,
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailed")]
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailedDays")]
    [switch]$Force,
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailed")]
    [DateTime]$StartDate,
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailed")]
    [DateTime]$EndDate,
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailedDays")]
    [ValidateRange(1, 10)]
    [Int16]$Days,
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailed")]
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailedDays")]
    [switch]$SkipConnectionCheck,
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailed")]
    [Parameter(Mandatory = $false, ParameterSetName = "ResendCopyFailedDays")]