Create a self signed SSL certificate
Create and install a self signed SSL certificate (with the SelfSSL7 utility)
<# .SYNOPSIS SelfSSL - Create and install a self signed SSL certificate. .NOTES File Name : SelfSSL.ps1 Author : Fabrice ZERROUKI - fabricezerrouki@hotmail.com .EXAMPLE PS D:\>SelfSSL.ps1 #> Param( [Parameter(Mandatory=$true, HelpMessage="You must provide a website name.")] [string]$Website ) $IPAddress = Get-WmiObject Win32_NetworkAdapterConfiguration | Where { $_.DefaultIPGateway -ne $null } -ErrorAction SilentlyContinue $IP = $IPAddress | % {$_.IPAddress} $TempFolder = "D:\DOWNLOADED_APPLICATIONS" if(!(Test-Path $TempFolder)) {New-Item -Path $TempFolder -Type directory} $SelfSSL7 = "D:\DOWNLOADED_APPLICATIONS\selfssl7.exe" Function Unzip($ZipFile, $UnzipPath) { $ShellApplication = New-Object -com Shell.Application $ZipPackage = $ShellApplication.NameSpace($ZipFile) $DestFolder = $ShellApplication.NameSpace($UnzipPath) $DestFolder.CopyHere($ZipPackage.Items()) } if (!(Test-Path ($SelfSSL7))) { # Download the SelfSSL7 utility Write-Host "Downloading selfssl7 utility..." -ForegroundColor DarkGreen; $src = "http://blogs.iis.net/blogs/thomad/SelfSSL7.zip" $dest = "D:\DOWNLOADED_APPLICATIONS\SelfSSL7.zip" $wc = New-Object System.Net.WebClient # Uncomment the next 2 lines if you have to use the IE configured proxy #$wc.UseDefaultCredentials = $true #$wc.Proxy.Credentials = $wc.Credentials $wc.DownloadFile($src, $dest) # Unzip the downloaded file Write-Host "Extracting selfssl7 utility..." -ForegroundColor DarkGreen; UnZip $dest $TempFolder } $args = " /N cn=$env:COMPUTERNAME /K 2048 /V 365 /I /S $Website /P443 /A $IP /T" Start-Process -FilePath $SelfSSL7 -ArgumentList $args -Wait Write-Host "`nSelf Signed SSL certificate for website $Website successfully created and installed!" -ForegroundColor DarkGreen; Remove-Item $TempFolder -recurse