2016-11-30 32 views
0

當我使用以下Powerhell腳本時,IIS中的我的網站的匿名身份驗證不會從「已啓用」更改爲「已禁用」。任何人可以幫助請: -Powershell - 無法在網站的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 

我也試過,但還是老樣子不起作用: -

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

我沒有收到任何錯誤RS。看起來腳本成功運行。

另外,有沒有人知道我將如何設置表單身份驗證禁用呢?

所以看起來像我能驗證設置爲「Enabled」如果我這樣做: -

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" 
+0

不知道這會工作,但也許嘗試在單引號包裹你的過濾器?它讀取'/'作爲轉義字符的可能性很小。 –

+0

嗨,邁克。感謝您的幫助,但不幸的是,這並沒有工作:-(。 – ED209

+0

你可以嘗試寫False而不是假的 –

回答

0

好吧,我有解決方案: -

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

所以你說,設置爲true將禁用匿名?嗯... –

+0

對我來說這不起作用,因爲IIS要求參數的名稱。我將它設置爲-Name Enabled,但是然後得到與上面相同的錯誤。 – GrahamJ