如何使用 IISAdministration PowerShell 模块添加动词

问题描述 投票:0回答:1

背景

我正在为 IIS 10 和 CIS 基准测试审核和强化脚本。我知道这可以使用较旧的 WebAdministration 模块或使用 appcmd 可执行文件来完成,但我正在尝试通过 IISAdministration 模块来完成尽可能多的操作。

问题

我正在尝试应用满足 CIS 基准“4.6 确保禁用‘HTTP 跟踪方法’”所需的更改。我可以获得动词,但到目前为止我无法将动词添加到“requestFiltering”中。

我可以得到动词..

$requestConfigSection = Get-IISConfigSection -SectionPath 'system.webServer/security/requestFiltering'
$verbsElements = Get-IISConfigElement -ConfigElement $requestConfigSection -ChildElementName 'verbs'

如果痕迹已经存在,我可以像这样得到它。

$traceVerb = Get-IISConfigAttributeValue -ConfigElement $verbsElements -AttributeName 'trace'

然后这样设置。

Set-IISConfigAttributeValue -ConfigElement $verbsElements -AttributeName 'trace' -AttributeValue $false

如何添加不存在的动词? 我正在寻找此版本的 IIS 管理模块...

Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/security/requestFiltering/verbs" -name "." -value @{verb='TRACE';allowed='False'}
powershell iis iis-10
1个回答
0
投票

我在“请求过滤”模块中添加了动词“trace”。

但是当我使用以下命令时,它给了我一个错误:

$requestConfigSection = Get-IISConfigSection -SectionPath 'system.webServer/security/requestFiltering'
$verbsElements = Get-IISConfigElement -ConfigElement $requestConfigSection -ChildElementName 'verbs'
Get-IISConfigAttributeValue -ConfigElement $verbsElements -AttributeName 'trace'

如果动词“trace”已经存在,你如何得到它?

© www.soinside.com 2019 - 2024. All rights reserved.