使用Powershell切换IIS功能委派

时间:2016-02-01 22:10:48

标签: powershell iis

如何更改IIS"功能委派"使用Powershell。我想改变"身份验证 - 匿名"读/写。 我找到了这个Toggle IIS 7.5 Authentication "Anonymous Authentication" with Powershell 3.0?,但不确定如何为"特征委派"做类似的事情。感谢。

2 个答案:

答案 0 :(得分:5)

终于找到了这个链接并帮助了

  

http://forums.iis.net/t/1178408.aspx?PowerShell+command+Feature+Delegation+settings

以下是一些例子。

Set-WebConfiguration //System.WebServer/Security/Authentication/anonymousAuthentication
-metadata overrideMode -value Allow -PSPath IIS:/

Set-WebConfiguration //System.WebServer/Security/Authentication/windowsAuthentication
-metadata overrideMode -value Deny -PSPath IIS:/

答案 1 :(得分:1)

如果您需要上面的Get for this set,请举例说明:

Get-WebConfiguration //System.WebServer/Security/Authentication/anonymousAuthentication -pspath iis:/ | select *

Function Enable-WindowsFeatureDelegation
{
    $delegateSet = (Get-WebConfiguration //System.WebServer/Security/Authentication/windowsAuthentication -pspath iis:/).Overridemode
    if($delegateSet -eq 'Deny')
    {
        Set-WebConfiguration //System.WebServer/Security/Authentication/windowsAuthentication -metadata overrideMode -value Allow -PSPath IIS:/
        Write-Output "Feature Delegation for windowsAuthentication has been set to Allow"
    }
}

Function Disable-WindowsFeatureDelegation
{
    $delegateSet = (Get-WebConfiguration //System.WebServer/Security/Authentication/windowsAuthentication -pspath iis:/).Overridemode
    if($delegateSet -eq 'Allow')
    {
        Set-WebConfiguration //System.WebServer/Security/Authentication/windowsAuthentication -metadata overrideMode -value Deny -PSPath IIS:/
        Write-Output "Feature Delegation for windowsAuthentication has been set to Deny"
    }
}