Home
Operating System
Windows
Linux
Tutorial
Windows Server
About
☰
SSL TO WEBSITE
# New Forward Lookup Zone
Add-DnsServerPrimaryZone -Name "example.com" -ZoneFile "example.com.dns"
✏️ Edit
📋 Copy
Copied!
# Convert to AD-Integrated Zone
ConvertTo-DnsServerPrimaryZone -Name "example.com" -ReplicationScope Domain
✏️ Edit
📋 Copy
Copied!
# Create A record
Add-DnsServerResourceRecordA -ZoneName "example.com" -Name "www" -IPv4Address "172.31.255.14"
✏️ Edit
📋 Copy
Copied!
# Install IIS Feature
Add-WindowsFeature Web-Server, Web-Mgmt-Console
✏️ Edit
📋 Copy
Copied!
# Make Folder and The Simple Html
mkdir c:\Website cd c:\website New-Item -Path . -Name "index.html" -ItemType "File" -Value @"
Hello World
"@
✏️ Edit
📋 Copy
Copied!
# Import Module WebAdministration
Import-Module WebAdministration
✏️ Edit
📋 Copy
Copied!
# New Https Site
New-Website ` -Name "TEST SSL" ` -PhysicalPath "C:\website" ` -Port 443 ` -HostHeader "www.example.com" ` -Ssl
✏️ Edit
📋 Copy
Copied!
# Add Port
New-WebBinding -Name "TEST SSL" ` -IPAddress "*" ` -Protocol "https" ` -Port 40 ` -HostHeader "www.example.com"
✏️ Edit
📋 Copy
Copied!
# List Website
Get-Website
✏️ Edit
📋 Copy
Copied!
## Remove Port
Remove-WebBinding -Name "TEST SSL" -Port 443
✏️ Edit
📋 Copy
Copied!
# Create SSL
New-SelfSignedCertificate -CertStoreLocation cert:\localmachine\my -DnsName "SSL" | Export-PfxCertificate -FilePath "myweb.pfx" -Password (ConvertTo-SecureString -String "Password" -Force -AsPlainText)
✏️ Edit
📋 Copy
Copied!
# List SSL
Get-ChildItem Cert:\LocalMachine\My
✏️ Edit
📋 Copy
Copied!
## Remove SSL
Get-ChildItem Cert:\LocalMachine\My | Where-Object { $_.Subject -like "*SSL*" } | Remove-Item
✏️ Edit
📋 Copy
Copied!
# Find your SSL certificate
$cert = Get-ChildItem cert:\LocalMachine\My | Where-Object { $_.Subject -match "CN=SSL" } | Select-Object -First 1
✏️ Edit
📋 Copy
Copied!
# Attach it to phpSite HTTPS
Get-WebBinding -Name "TEST SSL" -Protocol "https" | ForEach-Object { $_.AddSslCertificate($cert.Thumbprint, "My") }
✏️ Edit
📋 Copy
Copied!
# Remove Default Web Site
Remove-Website -Name "Default Web Site"
✏️ Edit
📋 Copy
Copied!
# Start Website
Start-Website -Name "TEST SSL"
✏️ Edit
📋 Copy
Copied!
# Restart IIS
iisreset
✏️ Edit
📋 Copy
Copied!
# Allow port 40 to client
New-NetFirewallRule ` -DisplayName "Allow HTTPS 40" ` -Direction Inbound ` -Protocol TCP ` -LocalPort 40 ` -Action Allow
✏️ Edit
📋 Copy
Copied!
Labels
all
(21 )
autocad
(3 )
css
(2 )
linux
(5 )
op_system
(18 )
website
(4 )
windows
(14 )
windowsServer
(17 )