Joseph Joseph - 4 months ago 49
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


Answer

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
$winKernel 
$winProviders = Get-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -location 'Default Web Site' -filter "$windowsAuthFilter/providers" -name "." 
$winProviders.Collection | Format-Table value
Comments