Powershell - 无法在IIS中禁用网站的匿名身份验证

时间:2016-11-30 14:08:21

标签: powershell authentication iis anonymous

当我使用以下Powerhell脚本时,IIS中我网站的匿名身份验证不会从“已启用”更改为“已禁用”。有人可以帮忙吗: -

Import-Module WebAdministration

Set-WebConfigurationProperty -filter /system.webServer/security/authentication/anonymousAuthentication -name enabled -value false -PSPath IIS:\Sites\myWebsite -Force

我也试过这个: -

    Set-WebConfigurationProperty -filter /system.webServer/security/authentication/anonymousAuthentication -name disable -value true -PSPath IIS:\Sites\myWebsite -Force

我也尝试过: -

Set-WebConfigurationProperty -filter '/system.webServer/security/authentication/anonymousAuthentication' -name enabled -value false -PSPath IIS:\Sites\myWebsite -Force

我也试过这个,但stil不起作用: -

Set-WebConfigurationProperty -Filter /system.webServer/security/authentication/anonymousAuthentication -name Enabled -value False -PSPath 'IIS:\' -Location "Sites\myWebsite"

我没有收到任何错误。该脚本似乎成功运行。

另外,是否有人知道如何将表单身份验证设置为禁用?

因此,如果我执行此操作,我可以将身份验证设置为“已启用”: -

Set-WebConfigurationProperty -Filter /system.webServer/security/authentication/anonymousAuthentication -name Enabled -value true -Location "IIS:\Sites\myWebsite"

但如果我这样做,我无法将身份验证设置为“已禁用”: -

Set-WebConfigurationProperty -Filter /system.webServer/security/authentication/anonymousAuthentication -name Enabled -value false -Location "IIS:\Sites\myWebsite"

4 个答案:

答案 0 :(得分:1)

好的我有解决方案: -

Set-WebConfiguration system.webServer/security/authentication/anonymousAuthentication -PSPath IIS:\ -Location myWebsite -Value @{enabled="True"}

答案 1 :(得分:0)

Import-Module WebAdministration
Set-WebConfigurationProperty -filter /system.webServer/security/authentication/anonymousAuthentication -name enabled -value false -PSPath IIS:\\ -location ${site_name}/${virtual_directory_name}

这应该做您想要的。用启用的true和false值运行并在IIS中验证。

答案 2 :(得分:0)

这肯定可以正常工作,只需正确检查您的IIS路径即可。

Import-Module WebAdministration
Set-WebConfigurationProperty -filter /system.WebServer/security/authentication/AnonymousAuthentication -name enabled -value false -location "IIS:\Sites\Default Web Site\NMFD"

答案 3 :(得分:0)

如果以上都不起作用,并且如果有人仍在寻找答案,这对我有用

Set-WebConfigurationProperty -Filter '/system.webServer/security/authentication/anonymousAuthentication' -Name enabled -Value False -PSPath 'MACHINE/WEBROOT/APPHOST/Default Web Site'

基本上我从下面的命令中获取了 PSPath

Get-WebConfiguration -filter /system.webServer/security/authentication/anonymousAuthentication 'iis:\sites\Default Web Site' |select *