Powershell脚本来验证IIS设置
问题描述:
是否可以使用Power Shell脚本获取IIS设置?Powershell脚本来验证IIS设置
我希望得到/使用AA脚本检查以下信息:
- 检查的Windows身份验证提供正确列出(协商,NTLM)
- 检查Windows身份验证启用
- Windows身份验证高级设置 - >启用内核模式是
答
是的,这是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
答
下面是阅读匿名和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汉道夫 依然没有找到任何线索
检查Windows身份验证高级设置 - >启用内核模式并且
检查检查启用提供商,如NTLM和协商
+0
我在我的答案中添加了一些示例代码 –
已检索: 导入模块Web管理 cd IIS: IIS:\> Get-WebConfiguration -Filter“System.WebServer/Securit y /认证/ */*“ - 撤销|其中{$ _。enabled -eq $ True} | Format-List ' 但是得到如下错误: IIS:\> Get-WebConfiguration:术语'IIS:\> Get-WebConfiguration'不被识别为cmdlet,函数,脚本文件或可操作的名称程序。检查名称的拼写,或者如果包含路径 ,请验证路径是否正确,然后重试。 – Joseph
运行'Enable-WindowsOptionalFeature -nline -FeatureName IIS-WebServerManagementTools'来安装IIS cmdlet,如果您有较旧的Windows版本,则通过GUI安装它们。 –
下面的代码运行正常,但在输出时,它不显示如果Windows身份验证已启用或未启用IIS: Get-WebConfiguration system.webServer/security/authentication/windowsAuthentication/*'IIS:\ sites \ Default Web Site' - 撤销| format-list – Joseph