Joseph Joseph - 10 months ago 144
PowerShell Question

Powershell script to verify IIS Settings

Is it to possible to get IIS settings using Power Shell Script?

I am looking to get/check below information using a a script:

  1. Check if Windows Authentication Providers are listed correctly (Negotiate, NTLM)

  2. Check if Windows Authentication is enabled

  3. Windows Authentication Advanced Settings -> enable kernel-mode is on


Yes that is all easily possible with PowerShell.

There are lots of samples and examples online

Look at the (IIS) Administration Cmdlets in Windows PowerShell

and especially Get-WebConfiguration and Get-WebConfigurationProperty

To get information about the Windows Authentication Advanced Settings use:

$windowsAuthFilter = "/system.WebServer/security/authentication/windowsAuthentication"

$winKernel = (Get-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -location 'Default Web Site' -filter "$windowsAuthFilter" -name "useKernelMode").Value
$winProviders = Get-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -location 'Default Web Site' -filter "$windowsAuthFilter/providers" -name "." 
$winProviders.Collection | Format-Table value