【问题标题】:How can I use PowerShell to set the default document in IIS?如何使用 PowerShell 在 IIS 中设置默认文档?
【发布时间】:2010-11-05 19:54:40
【问题描述】:

我正在使用 PowerShell 配置网站,并且我想设置默认文档。我该怎么做?

【问题讨论】:

    标签: powershell iis-6


    【解决方案1】:

    这是一种方式:

    $metabasePath = "IIS://Localhost/W3SVC"
    $iisNumber = "12345"
    $site = new-object 
            System.DirectoryServices.DirectoryEntry("$metabasePath/$iisNumber/root")
    $site.psbase.Properties["DefaultDoc"].Value = 
        "newdefdoc.htm," + $site.psbase.Properties["DefaultDoc"].Value
    $site.psbase.CommitChanges()
    

    $site.psbase.Properties["DefaultDoc"].Value 中返回的值是一个以逗号分隔的文档列表,因此您可能需要重新调整顺序以适合您的情况。上面的示例只是在列表顶部添加了一个新的默认文档 (newdefdoc.htm)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-11
      • 2016-07-05
      • 2011-07-08
      • 2015-05-02
      • 2021-02-19
      • 2014-04-13
      • 2016-02-06
      相关资源
      最近更新 更多