Microsoft.Web.Administration; IIS Security; Enable default authentication methods


I needed to set up IIS 7 for a whole bunch of servers.
Part of the requiremants was to Enable default authentication methods
The manual way was like this:

In IIS Manager, click on Server Name again
Scroll down and double click Authentication
Right Click the Windows Authentication and select Enable
Right Click the Windows Authentication and select Advanced Settings
Uncheck the box for “Enable kernel-mode authentication”
Right click ASP.NET Impersonation and select Enable
Right click on Basic Authentication and select Enable (for F5 monitoring)
So the powershell way is like this:
I never did figure out how to Uncheck the box for “Enable kernel-mode authentication”
So i did it with appcmd.exe
#>

If ((Get-Module "WebAdministration" -ErrorAction SilentlyContinue) -eq $null){
Import-Module WebAdministration
}

if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}

if ((Get-Module "ServerManager" -ErrorAction SilentlyContinue) -eq $null) {
    Import-Module "ServerManager"
}


Set-WebConfigurationProperty -filter /system.webServer/security/authentication/anonymousAuthentication -name enabled -value False -PSPath IIS:\
Set-WebConfigurationProperty -filter /system.webServer/security/authentication/basicAuthentication -name enabled -value True -PSPath IIS:\
Set-WebConfigurationProperty -filter /system.webServer/security/authentication/windowsAuthentication -name enabled -value True -PSPath IIS:\
cd $env:windir\system32\inetsrv
.\appcmd.exe set config "Default Web Site" -section:system.webServer/security/authentication/windowsAuthentication /useKernelMode:"False"  /commit:apphost

Set-WebConfigurationProperty -Name impersonate -Filter system.web/identity -Value True
Advertisements

7 thoughts on “Microsoft.Web.Administration; IIS Security; Enable default authentication methods

  1. Very nice I couldn’t find this import module that covers both iis 7 and 7.5 which is annoying but I’m happy that I have you blog handy.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s