【发布时间】:2021-08-06 16:28:34
【问题描述】:
我需要识别允许跨企业中所有主机进行 NTLM 身份验证的 IIS 站点。 PowerShell 已经安装在每台主机上,因此 PowerShell 似乎是显而易见的解决方案。
我没有在 PowerShell 上花费很多时间,但这是我迄今为止想出的代码。它似乎正确地遍历了我的站点列表,并且我可以获取 providers 元素,但我无法检查 add 元素属性的值。
我还尝试使用“类似问题”功能查看其他问题和答案。
这是代码
$site_list = Get-IISSite
foreach($site in $site_list)
{
$ConfigSection = Get-IISConfigSection("system.webServer/security/authentication/windowsAuthentication")
foreach ($attribute in $ConfigSection.Attributes)
{
if($attribute.Name -eq "enabled")
{
Write-Host $site.Name : $attribute.Name : $attribute.Value
}
}
foreach($element in $ConfigSection.ChildElements)
{
if ($element.ElementTagName -eq "providers")
{
Write-Host ChildElements.Count : $element.ChildElements.Count
$element.Attributes
$element|fl
Write-Host Attributes Count : $element.Attributes.Count
#$elem_attributes = $element.Attributes
foreach ($elem_attr in $elem_attributes)
{
Write-Host $elem_attr
}
}
}
}
我的 format-list 输出显示了一个子元素,其 ElementTagName 为 add,属性为 Value。但是,当我显示 Attributes 属性的 Count() 时,它显示为 0。我认为 OOP 术语以及 XML 元素和属性令人困惑,因此我的某些术语可能不正确。任何人都可以提供的任何帮助或指导都会有所帮助。
这是元素格式列表的示例输出。
Attributes : {value}
ChildElements : {}
ElementTagName : add
IsLocallyStored : True
Methods :
RawAttributes : {[value, Negotiate]}
Schema : Microsoft.Web.Administration.ConfigurationElementSchema
Attributes : {value}
ChildElements : {}
ElementTagName : add
IsLocallyStored : True
Methods :
RawAttributes : {[value, NTLM]}
Schema : Microsoft.Web.Administration.ConfigurationElementSchema
【问题讨论】:
标签: powershell iis ntlm