Hi every one. I got powershell script that create IIS pool/site now i need to make it switch between Forms/Windows auth. The problem is when i create it with forms auth i cant disable it so if i create new IIS with windows auth i have forms and windows auth and this is a problem.So my question is how i can disable forms auth using powershell.
Hi Dragomir,
Here is a nice example.
http://forums.iis.net/t/1165277.aspx?How+can+I+use+a+powershell+script+to+modify+authentication
and here is a reference to the names of the different authentication methods
https://www.iis.net/configreference/system.webserver/security/authentication
already try this two suggestion but still i cant disable from auth if i create windows auth IIS site first
If you can share your script via gist or similar, we can try to see what’s happening
i fix it 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”