@richardwolford-7948
I need to set the site to require SSL
You can retrieve the binding information of your site using the Get-WebBinding cmdlet and set the SSL Certificate using the AddSslCertificate function:
$siteName = 'mywebsite'
$dnsName = 'www.mywebsite.ru'
# create the ssl certificate
$newCert = New-SelfSignedCertificate -DnsName $dnsName -CertStoreLocation cert:\LocalMachine\My
# get the web binding of the site
$binding = Get-WebBinding -Name $siteName -Protocol "https"
# set the ssl certificate
$binding.AddSslCertificate($newCert.GetCertHashString(), "my")
I need to redirect HTTP to HTTPS
You can refer to this link: PowerShell script that automatically adds a HTTP to HTTPS redirect rule to a web site's web.config..
More information about this question you can refer to below links:
How to configure SSL on IIS with PowerShell.
How to configure SSL on IIS with PowerShell.
Create a http to https URL redirect in IIS with Powershell.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.