【问题标题】:How to use DSC to confgure httpErrors defaultPath如何使用 DSC 配置 httpErrors defaultPath
【发布时间】:2019-09-23 12:36:24
【问题描述】:

在 IIS 的 DSC 配置脚本中,我试图从 httpErrors 部分删除 defaultPath 锁,但功能委派的工作方式不适用于此部分。因此要做到以下几点:

appcmd set config /section:httpErrors /lockAttributes:

我尝试使用 xWebConfigProperty,如下所示:

xWebConfigProperty httpErrors_lockAttributes
{
    WebsitePath = "MACHINE/WEBROOT/APPHOST"
    Filter = "system.webServer/httpErrors"
    PropertyName = "lockAttributes"
    Value = ""
    Ensure = "Absent"
}

但是,这会失败并显示 lockAttributes 属性不存在的错误。然而它肯定在 ApplicationHost.config 中

我唯一剩下的解决方法是在 DSC 中将 appcmd 作为脚本运行(有点难看)。有什么想法吗?

【问题讨论】:

    标签: powershell iis dsc


    【解决方案1】:

    您可以使用以下 PowerShell 命令从默认路径中删除锁定:

    Remove-WebConfigurationLock  -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.webServer/httpErrors/@defaultPath"
    

    【讨论】:

    • 我同意这是可行的,但 appcmd 命令也是如此,但我正在寻找一个 DSC 配置脚本来执行此操作。
    【解决方案2】:

    我知道这已经很老了。但是我发现很多这些模块和资源都是为特定任务而构建的,并且不像其他 DSC 工具那样模块化。如果您想要一个“纯”的 DSC 解决方案,您可能必须创建一个自定义资源来处理其 set/get/test 函数中的 Remove-WebConfigurationLock。如果没有,DSC 脚本资源将满足您的需求。

    【讨论】:

      猜你喜欢
      • 2018-03-04
      • 2023-03-26
      • 2011-12-16
      • 1970-01-01
      • 2017-09-16
      • 1970-01-01
      • 2021-01-20
      • 2023-03-11
      • 1970-01-01
      相关资源
      最近更新 更多