PoshCode Archive  Artifact [daa509f09b]

Artifact daa509f09bc990ebd653a0d27917e116fe0d7840e458d47cda724e06b0235f42:

  • File Add-SSL-Cert-to-IIS.ps1 — part of check-in [bffd24dc9f] at 2018-06-10 13:14:20 on branch trunk — How to add a SSL Certificate to IIS with Powershell as well as set the SSL Binding for the site that’s using the certificate. (user: Brian H Madsen size: 861)

# encoding: ascii
# api: powershell
# title: Add SSL Cert to IIS
# description: How to add a SSL Certificate to IIS with Powershell as well as set the SSL Binding for the site that’s using the certificate.
# version: 0.1
# type: function
# author: Brian H Madsen
# license: CC0
# function: Add-SSLCertificate
# x-poshcode-id: 2684
# x-archived: 2016-05-18T14:28:25
# x-published: 2011-05-18T21:50:00
#
# This uses a PFX certificate file.
#
function Add-SSLCertificate{
    param([string]$pfxPath,[string]$pfxPassword,[string]$hostHeader,[string]$siteName)

    $certMgr = New-Object -ComObject IIS.CertObj -ErrorAction SilentlyContinue    
    $certMgr.ImportToCertStore($pfxPath,$pfxPassword,$true,$true)

    Import-Module WebAdministration;
    New-WebBinding -Name $siteName -Port 443 -Protocol https -HostHeader $hostHeader    
}