简体   繁体   中英

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?

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

Thanks a lot.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM