用于验证IIS设置的Powershell脚本

时间:2016-08-02 14:03:08

标签: windows powershell iis

是否可以使用Power Shell Script获取IIS设置?

我希望使用脚本获取/检查以下信息:

  1. 检查是否正确列出了Windows身份验证提供程序(Negotiate,NTLM)
  2. 检查是否启用了Windows身份验证
  3. Windows身份验证高级设置 - >启用内核模式

2 个答案:

答案 0 :(得分:2)

是的,PowerShell可以轻松实现这一切。网上有很多样本和例子。

查看(IIS) Administration Cmdlets in Windows PowerShell 尤其是Get-WebConfigurationGet-WebConfigurationProperty

要获取有关Windows身份验证高级设置的信息,请使用:

$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

答案 1 :(得分:0)

以下是阅读匿名和Windows身份验证的答案:

$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

仍未找到任何线索

检查Windows身份验证高级设置 - >启用内核模式并且

检查检查启用提供程序,如NTLM和Negotiate