4
votes

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.

2

2 Answers

2
votes

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.

1
votes

If you are trying to get the Forms authentication for the main panel of IIS , you can use the below script...

Get-WebConfiguration system.web/authentication -PSPath "MACHINE/WEBROOT" | Select-Object -ExpandProperty mode

If you are looking for a particular Site,include the path of the site/application too