Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating IIS7 web application using PowerShell with Require SSL set to "Require"

I'm creating an IIS web site using PowerShell's New-WebSite cmdlet, and within that a web application using New-WebApplication.

The SSL settings for the web application need to be set to Require SSL; Require as shown below.

IIS SSL Settings

For consistency, I would like to do this using only PowerShell cmdlets.

The Require SSL setting is easy; you just add the -Ssl parameter to New-Website.

However, the only way we've found to set the Require option is using Appcmd.exe:

& $env:SystemRoot\System32\inetsrv\Appcmd.exe `
    set config "$WebSiteName/$VirtualDirName" `
    /section:access `
    /sslFlags:"SslRequireCert" `
    /commit:APPHOST

Is there a PowerShell alternative to this?

like image 956
Richard Ev Avatar asked Feb 14 '13 14:02

Richard Ev


1 Answers

I had to add ssl to the value:

Set-WebConfiguration -Location "$WebSiteName/$WebApplicationName" -Filter 'system.webserver/security/access' -Value "Ssl, SslRequireCert"

like image 174
user2182089 Avatar answered Oct 06 '22 21:10

user2182089