Add-SSLCertificate

Installs a .pfx file

Function Add-SSLCertificate{
    param([string]$pfxPath,[string]$pfxPassword,[string]$HostHeader,[string]$Website)
 
    Import-Module "WebAdministration" -ErrorAction Stop
    $certMgr = New-Object -ComObject IIS.CertObj -ErrorAction SilentlyContinue    
    $certMgr.ImportToCertStore($PfxPath,$PfxPassword,$true,$true)
 
    New-WebBinding -Name $Website -Port 443 -Protocol https -HostHeader $HostHeader    
}

Leave a Reply

Scroll to Top