Author Posts

May 14, 2016 at 3:45 am

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.

May 15, 2016 at 11:57 pm

already try this two suggestion but still i cant disable from auth if i create windows auth IIS site first

May 16, 2016 at 12:47 am

If you can share your script via gist or similar, we can try to see what's happening

May 16, 2016 at 3:58 am

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"