Jay*_*aty 22 iis powershell web-deployment
我知道如何通过以下命令为IIS网站设置此项:
Set-WebConfigurationProperty -filter "/system.webServer/security/authentication/windowsAuthentication" -name enabled -value true -PSPath "IIS:\" -location $siteName
Run Code Online (Sandbox Code Playgroud)
但我想为该网站内的应用程序设置它.例如,我有一个名为"MySite"的IIS网站,其中有两个应用程序.我想为一个启用Windows身份验证而不为另一个启用Windows身份验证.因此,对于两者都将启用站点级别的启用,这是我不想要的.
Ric*_*los 36
我遇到了处理锁定部分的问题,并且接受的答案建议打开一个GUI来解决它,我试图首先避免使用PowerShell.
启用Windows身份验证并禁用匿名身份验证
$iisAppName = "MyApp"
Write-Host Disable anonymous authentication
Set-WebConfigurationProperty -Filter "/system.webServer/security/authentication/anonymousAuthentication" -Name Enabled -Value False -PSPath IIS:\ -Location "Default Web Site/$iisAppName"
Write-Host Enable windows authentication
Set-WebConfigurationProperty -Filter "/system.webServer/security/authentication/windowsAuthentication" -Name Enabled -Value True -PSPath IIS:\ -Location "Default Web Site/$iisAppName"
Run Code Online (Sandbox Code Playgroud)
如IIS文档中所述:
身份验证部分通常是锁定的,即它们不能写入web.config文件,而是必须写入中央applicationhost.config文件.
我们必须使用-PSPath
和-Location
参数.
Set-WebConfigurationProperty -filter /system.webServer/security/authentication/windowsAuthentication -name enabled -value true -PSPath IIS:\ -location DemoSite/DemoApp
Run Code Online (Sandbox Code Playgroud)
Jam*_*phy 23
你不需要单独-PSPath
和-Location
参数.你可以像这样组合它们:
-PSPath "IIS:\Sites\$SiteName\$AppName"
Run Code Online (Sandbox Code Playgroud)
所以实际命令看起来像这样:
Set-WebConfigurationProperty -Filter "/system.webServer/security/authentication/windowsAuthentication" -Name Enabled -Value True -PSPath "IIS:\Sites\$SiteName\$AppName"
Run Code Online (Sandbox Code Playgroud)
请注意,您可能会遇到此错误:
Set-WebConfigurationProperty:此配置节不能在此路径中使用.当该部分被锁定在父级别时会发生这种情况.锁定是默认情况下(overrideModeDefault ="Deny"),或由locationMode ="Deny"或遗留allowOverride ="false"的位置标记显式设置.
Tomfanning了在ServerFault提供的解决方案在这里.我在这里重复了他的步骤:
归档时间: |
|
查看次数: |
26553 次 |
最近记录: |