Created
January 17, 2022 22:34
-
-
Save shashank-shekhar/b088af93e2b368bf03cbda62cc6936e7 to your computer and use it in GitHub Desktop.
Create an IIS site, accopanying self signed certificate, and update hosts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This scripts create an IIS site with an SSL Certificate assigned to it | |
$siteName = 'sitename' | |
$sitepath = 'path to project' | |
Write-Host "Starting Site Creation for $siteName" | |
# Create Certificate | |
New-SelfSignedCertificate -Type SSLServerAuthentication -DnsName $siteName -CertStoreLocation 'cert:\LocalMachine\My' -KeyExportPolicy Exportable -KeyAlgorithm RSA -KeyLength 4096 | |
New-WebAppPool -Name $siteName | |
New-Website -Name $siteName -ApplicationPool $siteName -HostHeader $siteName -PhysicalPath $sitepath | |
New-WebBinding -Name $siteName -IPAddress "*" -Port 443 -Protocol https -HostHeader $siteName | |
# update hosts to add $siteName | |
Add-Content -Path C:\Windows\System32\drivers\etc\hosts -Value `n"127.0.0.1`t${siteName}" -Force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment