IIS下的身份验证方式管理
设置、查看身份验证方式
1 #导航到某站点下: 2 cd IIS:\Sites\DemoSite\DemoApp 3 4 #启用站点test01下的Windows身份验证 5 Set-WebConfigurationProperty -filter /system.webServer/security/authentication/windowsAuthentication -name enabled -value true -PSPath IIS:\ -Location test01 6 7 #启用站点default web site下应用程序pswa的Windows身份验证 8 Set-WebConfigurationProperty -filter /system.webServer/security/authentication/windowsAuthentication -name enabled -value true -PSPath IIS:\ -Location 'default web site/pswa' 9 10 #禁用站点MySite下的匿名身份验证 11 Set-WebConfiguration system.webServer/security/authentication/anonymousAuthentication -PSPath IIS:\ -Location MySite -Value @{enabled="False"} 12 13 #启用Form身份验证 14 $config = (Get-WebConfiguration system.web/authentication 'IIS:\sites\Default Web Site') 15 $config.mode = "Forms" 16 $config | Set-WebConfiguration system.web/authentication 17 18 #为MySite添加身份NTLM和Negotiate身份验证方式 19 Add-WebConfiguration -Filter system.webServer/security/authentication/windowsAuthentication/providers -PSPath IIS:\ -Location MySite -Value NTLM 20 Add-WebConfiguration -Filter system.webServer/security/authentication/windowsAuthentication/providers -PSPath IIS:\ -Location MySite -Value Negotiate 21 22 23 #查看已安装的身份验证方式 24 Get-WebConfiguration -filter /system.webserver/security/authentication -PSPath iis:\ 25 26 #查看站点test01下的windowsAuthentication身份验证方式 27 Get-WebConfiguration -filter /system.webServer/security/authentication/windowsAuthentication -pspath iis:\ -Location test01 |select * 28 #同上(只是路径写法不同) 29 Get-WebConfiguration -filter /system.webServer/security/authentication/windowsAuthentication 'iis:\sites\test01' |select *
设置站点身份验证方式:
1 Set-WebConfigurationProperty -Filter system.webServer/security/authentication/anonymousAuthentication ` 2 -PSPath MACHINE/WEBROOT/APPHOST ` 3 -Location 'Default Web Site' ` 4 -Name Enabled ` 5 -Value $true
检查某个站点/应用程序下的身份验证方式是否已启用
方法一:
1 $siteName = "test01" 2 $authentications=Get-WebConfiguration -filter "system.webServer/security/authentication/*" -PSPath "IIS:\Sites\$siteName" 3 $authentications | % {$_ |Select ItemXPath,enabled}
方法二(笨方法):
#定义站点名称 $site = "test01" Import-Module WebAdministration #获取所有已安装的身份验证方式 $auths = Get-WebConfiguration -filter /system.webserver/security/authentication -PSPath IIS:\ $authnames = $auths.Sections.name Foreach ($auth in $authnames) { $authall = $auths.ItemXPath + "/" + $auth #查看站点下每个身份验证是否启用 Get-WebConfiguration -filter $authall -pspath IIS:\ -Location $site|select ItemXPath,Enabled }
IIS PowerShell 管理命令:http://technet.microsoft.com/en-us/library/ee790599.aspx
分类:
PowerShell
, IIS
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?