Search code examples
iispowershellforms-authentication

Forms authentication state IIS and powershell


I am pretty new to scripting and I have a task to create a powershell script that will check and print out state of all authentication types of IIS 7.0 and 7.5 Virtual Directories.

As you probably know there are 6 types of authentication (basic, windows, digest, forms, asp.net impersonation, anonymous).

For basic, windows, digest and anonymous I was using this command:

Get-WebConfigurationProperty -filter /system.web/security/authentication -name enabled "IIS:\Sites\My Site\"

But I cannot find command that can check state for Forms Authentication. Can you please help me on this?

e.g If on IIS Configuration Manager, Forms authentication is enabled, I want to get value in powershell that it is enabled.

Thanks a lot.


Solution

  • You can read the mode attribute's value in the authentication configuration element:

    (Get-WebConfiguration system.web/authentication 'IIS:\sites\Default Web Site').Mode
    

    It will be forms if Forms Authentication is enabled.