简体   繁体   中英

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

Below is the answer to read anonymous and windows authentication:

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

$value = 'false'
$AppName = "test"

$anonAuth = Get-WebConfigurationProperty -filter $anonAuthFilter -name Enabled -location $AppName
Write-Host  $anonAuth.Value


$winAuth = Get-WebConfigurationProperty -filter $windowsAuthFilter -name Enabled -location $AppName
Write-Host  $winAuth.Value

@Peter Hahndorf Still didn't find any clue for

Check Windows Authentication Advanced Settings -> enable kernel-mode is on and

Check check Enabled Providers like NTLM and Negotiate

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM