我有一个Powershell脚本正在检查IIS配置
$httpProtocolPath = "system.webServer/httpProtocol"
$foo = Get-IISConfigSection -SectionPath $httpProtocolPath | Get-IISConfigCollection -CollectionName "customHeaders"
我需要一些有关如何检查或至少将RawAttibutes
放入某些变量的帮助,以便我可以对其进行检查。
Thx
[更新]
由于@Tomek的Answer,现在可以正常工作了
$httpProtocolPath = "system.webServer/httpProtocol"
$httpProtocolSection = $Configuration.GetSection($httpProtocolPath)
$customHeadersCollection = $httpProtocolSection.GetCollection("customHeaders")
$customHeader = $customHeadersCollection | select rawattributes | select -ExpandProperty * | Where-Object {
$name = $_ | Get-IISConfigAttributeValue -AttributeName "name"
$value = $_ | Get-IISConfigAttributeValue -AttributeName "value"
($name -eq "StrictTransport-Security") #-and ([int]$value -gt 0)
}
答案 0 :(得分:1)
您可能想看看哪种数据类型是RawAttributes。通常要弄清楚我会使用Show-Object命令 https://blogs.technet.microsoft.com/heyscriptingguy/2015/10/26/spelunking-with-show-object/
对于这种确切的情况-这对我来说很好
$foo|select rawattributes|select -ExpandProperty *