【发布时间】:2016-08-02 14:03:07
【问题描述】:
是否可以使用 Power Shell 脚本获取 IIS 设置?
我希望使用脚本获取/检查以下信息:
- 检查是否正确列出了 Windows 身份验证提供程序(协商、NTLM)
- 检查是否启用了 Windows 身份验证
- Windows 身份验证高级设置 -> 启用内核模式已开启
【问题讨论】:
标签: windows powershell iis
是否可以使用 Power Shell 脚本获取 IIS 设置?
我希望使用脚本获取/检查以下信息:
【问题讨论】:
标签: windows powershell iis
是的,这一切都可以通过 PowerShell 轻松实现。网上有很多样例和例子。
看(IIS) Administration Cmdlets in Windows PowerShell 尤其是Get-WebConfiguration 和Get-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
【讨论】:
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerManagementTools 安装 IIS cmdlet,如果您有旧的 Windows 版本,请通过 GUI 安装它们。
下面是阅读匿名和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
@彼得·汉多夫 仍然没有找到任何线索
检查 Windows Authentication Advanced Settings -> enable kernel-mode is on and
检查启用的提供程序,例如 NTLM 和协商
【讨论】: