-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiisBinding.ps1
More file actions
27 lines (21 loc) · 829 Bytes
/
iisBinding.ps1
File metadata and controls
27 lines (21 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
$thumb = Read-Host "Enter the certificate thumbprint"
$cert = Get-ChildItem Cert:\LocalMachine\WebHosting |Where-Object {$_.Thumbprint -eq $thumb}
$siteAHttpHost = @(
"example.com",
"www.example.com"
)
$siteAHttpsHost = @(
"example.com",
"www.example.com"
)
$siteA = Read-Host "Enter the Site Name"
foreach ($hostname in $siteAHttpHost){
New-WebBinding -Name $siteA -IPAddress "*" -port 80 -HostHeader $hostname
}
foreach ($hostname in $siteAHttpsHost){
Remove-WebBinding -Name $siteA -IPAddress "*" -port 443 -HostHeader $hostname
New-WebBinding -Name $siteA -IPAddress "*" -port 443 -HostHeader $hostname -Protocol "https" -SslFlags 1
Remove-Item -Path "IIS:\SslBindings\!443!$hostname"
New-Item -Path "IIS:\SslBindings\!443!$hostname" -Value $cert -SSLFlags 1
}
# Expand as necessary