更新时间:2023-11-02 23:44:46
我很久以前写了一篇关于这个的博客文章.http://www.danielrichnak.com/powershell-iis7-teach-yoursel/一个>
I wrote a blog post about this quite a while back. http://www.danielrichnak.com/powershell-iis7-teach-yoursel/
下面的代码将遍历 system.webserver 级别的所有内容并解锁它.您可以根据需要定位不同的节点.
The below code will loop through everything in system.webserver level and unlock it. You can target different nodes as you see fit.
$assembly = [System.Reflection.Assembly]::LoadFrom("$env:systemrootsystem32inetsrvMicrosoft.Web.Administration.dll")
# helper function to unlock sectiongroups
function unlockSectionGroup($group)
{
foreach ($subGroup in $group.SectionGroups)
{
unlockSectionGroup($subGroup)
}
foreach ($section in $group.Sections)
{
$section.OverrideModeDefault = "Allow"
}
}
# initial work
# load ServerManager
$mgr = new-object Microsoft.Web.Administration.ServerManager
# load appHost config
$conf = $mgr.GetApplicationHostConfiguration()
# unlock all sections in system.webServer
unlockSectionGroup(
$conf.RootSectionGroup.SectionGroups["system.webServer"])
您的解决方案类似但又足够不同,我无法验证您的解决方案,但既然您说它有效 - 听起来不错.:)
Your solution is similar but different enough that I can't verify what you've got, but since you say it works - sounds good. :)