Functions/Helper/Certificate/Remove-ValentiaCertificatePFX.ps1

#Requires -Version 3.0

#-- Helper for certificate --#

function Remove-ValentiaCertificatePFX
{
    [CmdletBinding()]
    param
    (
        [parameter(mandatory = $false, position  = 0)]
        [ValidateNotNullOrEmpty()]
        [string]$CN = $valentia.certificate.CN,

        [parameter(mandatory = $false, position  = 1, ValueFromPipeline = 1, ValueFromPipelineByPropertyName = 1)]
        [ValidateNotNullOrEmpty()]
        [string]$PFXFilePath = $valentia.certificate.FilePath.PFX,

        [parameter(mandatory = $false, position  = 2)]
        [switch]$force = $false
    )
    
    $param = @{
        Path    = $PFXFilePath -f $CN
        Confirm = (-not $force)
        Force   = $force
    }
    if (Test-Path $param.Path)
    {
        Remove-Item @param
    }
}