Switch between Form/Windows authentication IIS using powershell

This topic contains 4 replies, has 3 voices, and was last updated by Profile photo of Dragomir Dimitrov Dragomir Dimitrov 4 months, 1 week ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #39079
    Profile photo of Dragomir Dimitrov
    Dragomir Dimitrov
    Participant

    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.

    #39080
    Profile photo of Curtis Smith
    Curtis Smith
    Participant
    #39107
    Profile photo of Dragomir Dimitrov
    Dragomir Dimitrov
    Participant

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

    #39110
    Profile photo of Arie H
    Arie H
    Participant

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

    #39116
    Profile photo of Dragomir Dimitrov
    Dragomir Dimitrov
    Participant

    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"

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.