简体   繁体   中英

PowerShell script that switch between Foms authentication and Windows authentication IIS

我得到了创建IIS网站/池的强大的Shell脚本。默认的网站是Form auth,我想将其从ps脚本切换到Windows auth。找到了怎么做,但是form auth不要禁用,并且我的form和win auth都被启用并且这是一个问题。如何禁用表单身份验证,以便我只能使用Windows身份验证?

To enable windows and disable forms auth:

$config = (Get-WebConfiguration system.web/authentication "IIS:\sites\$iisAppName")
$config.mode = "Windows"
$config | Set-WebConfiguration system.web/authentication
Set-WebConfigurationProperty -filter /system.webServer/security/authentication/windowsAuthentication -name enabled -value true -PSPath IIS:\ -location $iisAppName/$iisAppPoolName

To disable windows and enable forms:

$config = (Get-WebConfiguration system.web/authentication "IIS:\sites\$iisAppName")
$config.mode = "Forms"
$config | Set-WebConfiguration system.web/authentication

$winAuth = Get-WebConfiguration -filter /system.webServer/security/authentication/windowsAuthentication
$winAuth.enabled = $false
$winAuth | set-Webconfiguration -filter /system.webServer/security/authentication/windowsAuthentication -PSPath IIS:\ -location "$iisAppName"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM