5

我的 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 会更新。非常感谢任何线索和提示。

4

2 回答 2

4

或者使用一个衬垫:

Set-WebConfiguration system.web/authentication 'IIS:\sites\Default Web Site' -value @{mode='Forms'}
于 2012-10-25T08:52:45.123 回答
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-24T22:29:48.687 回答