【问题标题】:Configuring IIS with Powershell - Enable Forms Authentication使用 Powershell 配置 IIS - 启用表单身份验证
【发布时间】:2012-10-24 22:04:38
【问题描述】:

我的 IIS 如下所示:

Sites ->
        Default Web Site ->
                            MyWebApp

那么问题来了:如何在 MyWebApp 上启用 Forms Authentication?我设法更改或编辑匿名访问、基本和 Windows 身份验证。但是,Forms Auth 并不是那么容易。如何在 Powershell 中执行此操作?

我可以通过这种方式读取设置:

(Get-WebConfiguration system.web/authentication 'IIS:\sites\Default Web Site\MyWebApp').Mode

我在使用 Set-Webconfiguration 或 Set-Webconfigurationproperty 时遇到问题或没有运气。我发现这些 cmdlet 很难弄清楚。

更改发生在 web.config 中,当我在 IIS 管理器中点击启用或禁用表单身份验证时,至少 web.config 会更新。非常感谢任何线索和提示。

【问题讨论】:

    标签: iis powershell web-config forms-authentication


    【解决方案1】:

    或者用一个衬里:

    Set-WebConfiguration system.web/authentication 'IIS:\sites\Default Web Site' -value @{mode='Forms'}
    

    【讨论】:

      【解决方案2】:

      您在修改属性后将身份验证配置设置传递给 Set-Webconfiguration,以提供适当的过滤器:

      $config = (Get-WebConfiguration system.web/authentication 'IIS:\sites\Default Web Site')
      $config.mode = "Forms"
      $config | Set-WebConfiguration system.web/authentication
      

      注意:在尝试之前备份您的配置。

      【讨论】:

      猜你喜欢
      • 2012-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多