Skip to content

Instantly share code, notes, and snippets.

@gavi
Created January 27, 2019 03:07
Show Gist options
  • Save gavi/8902e3c7e432cf8144ea145e5ce32edb to your computer and use it in GitHub Desktop.
Save gavi/8902e3c7e432cf8144ea145e5ce32edb to your computer and use it in GitHub Desktop.
Bind SSL on Windows to a specific IP address and Certificate Thumbprint
function AddSSLBinding($fqdn,$ip,$thumbprint){
$cert = Get-ChildItem Cert:\LocalMachine\My\$($thumbprint)
New-WebBinding -Name $fqdn -IPAddress "$($ip)" -Port 443 -Protocol "https" -HostHeader $fqdn
$bind = Get-WebBinding -Name $fqdn -Protocol https
$bind.AddSslCertificate($cert.GetCertHashString(), "my")
}
#Usage Example
AddSSLBinding "test.domain.com" "10.0.0.1" "12344979A469750712B5EAC6168D85EC02E053FC"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment