Skip to content

Instantly share code, notes, and snippets.

@mahasak
Created April 20, 2016 09:10
Show Gist options
  • Save mahasak/6466c2253b0ca169a43daa0dee16017d to your computer and use it in GitHub Desktop.
Save mahasak/6466c2253b0ca169a43daa0dee16017d to your computer and use it in GitHub Desktop.
#Get Hostname
$env:computername
(Get-WmiObject -Class Win32_ComputerSystem -Property Name).Name
#Define Common Name
$cname = "CN=MyTestServer"
#Generate Self-Sign Certificate for IIS
makecert -r -pe -n $cname -b 01/01/2016 -e 01/01/2017 -eku 1.3.6.1.5.5.7.3.1 -ss my -sr localMachine -sky exchange -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12
cd IIS:\SslBindings
#Get Cert Thumbprint
$Thumbprint = (Get-ChildItem -Path Cert:\LocalMachine\My | Where-Object {$_.Subject -match $cname}).Thumbprint;
New-WebBinding -Name "Default Web Site" -IP "*" -Port 443 -Protocol https
Get-WebBinding 'Default Web Site'
PS IIS:\> cd SslBindings
PS IIS:\SslBindings> dir
PS IIS:\SslBindings> get-item cert:\LocalMachine\MY\$Thumbprint | new-item 0.0.0.0!5443
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment