代码之家  ›  专栏  ›  技术社区  ›  Marc Gravell

用于配置IIS6的开发工具

  •  13
  • Marc Gravell  · 技术社区  · 17 年前

    IIS6

    从开发人员的角度来看,我经常更改IIS设置,或者需要将其他团队的设置合并到不同的VM中。“将配置保存到磁盘”对我来说从来都不太奏效。

    因为我们正在进行许多小的更改,所以web安装项目也从未真正奏效。..针对web管理员的工具不一定适合开发人员——我们有不同的目标和需求。

    有人有脚本/工具/实用程序可以让我们快速配置IIS吗?特别地:

    • 移除 一切 (开始清洁)
    • 设置为应用程序
    • 设置应用程序池(我们假设应用程序池已经存在)

    从一些平面输入列表的发现(任何格式都可以)。

    6 回复  |  直到 17 年前
        1
  •  11
  •   David McEwing    17 年前

    1. Powershell卡入。
    2. MSBuild脚本。可能更难配置,但 MSBuild Extension Pack

        2
  •  4
  •   Richard    17 年前
        3
  •  4
  •   Nigel Holland    16 年前

    我参加这个节目有点晚了,但我认为这个PowerShell脚本很有用,请注意,我只在本地开发箱中使用它,所以很抱歉出现了神奇的数字。

    AuthFlags=4是集成授权

    这并不完全符合马克的要求,但这是一个良好的开端。

    如果你下载 WMI Tools

    function CreateAppPool($poolName,$userName,$password)
    {
        [wmiclass] $appPoolSettings = "root\MicrosoftIISv2:IISApplicationPoolSetting";
        $newPool = $appPoolSettings.CreateInstance();
        $newPool.Name = "W3SVC/AppPools/" + $poolName;
        $newPool.WAMUsername = $userName;
        $newPool.WAMUserPass = $password;
        $newPool.AppPoolIdentityType = 3;
        $newPool.Put();
        # Do it again if it fails as there is a bug with Powershell/WMI
        if (!$?)
        {
            $newPool.Put(); 
        }
    }
    
    
    function CreateWebsite($webSiteName, $path, $port, $appPoolName)
    {
        [wmiclass] $bindingClass = 'root\MicrosoftIISv2:ServerBinding';
        $bindings = $bindingClass.CreateInstance();
        $bindings.Port = $port;
        $webService = Get-WmiObject -namespace "root\MicrosoftIISv2" -class "IIsWebService";
        $webSite = $webService.CreateNewSite($webSiteName, $bindings, $path);
        [int] $index = $webSite.ReturnValue.IndexOf("'") + 1;
        [int] $length = $webSite.ReturnValue.Length - $index - 1;
        [string] $websiteID = $webSite.ReturnValue.SubString($index, $length)  + "/root";
        $webVirtualDirSetting = Get-WmiObject -namespace "root\MicrosoftIISv2" -class "IIsWebVirtualDirSetting" | Where-Object {$_.Name -eq $websiteID};
        $webVirtualDirSetting.AppFriendlyName = $webSiteName;
        $webVirtualDirSetting.AppPoolId = $appPoolName;
        $webVirtualDirSetting.AccessFlags = 517;
        $webVirtualDirSetting.AuthFlags = 4;
        $webVirtualDirSetting.Put();
    
        #Switch the Website to .NET 2.0
        C:\windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -sn W3SVC/
    }
    
    $webSiteName = "MyWebsiteName";
    $webSitePath = "C:\MyWebsitePath";
    $webSitePort = "9001";
    $appPoolName = "MyWebsitePool";
    $appPoolIdentity = "MYDESKTOP\MyWebsiteIdentity";
    $appPoolPassword = "MyWebsitePassword"; 
    
    CreateAppPool $appPoolName $appPoolIdentity $appPoolPassword
    CreateWebsite $webSiteName $webSitePath $webSitePort $appPoolName
    
        4
  •  1
  •   Wyatt Barnett    17 年前

    可能更容易的是在IIS7上标准化,所有这些东西都存在于web.config文件中,使生活变得更容易。

        5
  •  1
  •   CodeRot    17 年前

    您可能希望查看IIS的元数据库XML配置文件,并允许直接编辑。

    推荐文章