默认 FTP 站点级设置 <ftpServer>

概述

<siteDefaults> 元素的 <ftpServer> 元素指定所有 FTP 站点的 FTP 功能默认设置。

在 IIS 6.0 中,FTP 服务的设置存储在元数据库中与网站不同的单独部分中。 在 IIS 7 及更高版本中,FTP 设置存储在 ApplicationHost.config 文件中与存储网站设置相同的 <site><siteDefaults> 元素中。 因此,不能委托在 <ftpServer> 元素中指定的设置,也不能在 <location> 元素中指定这些设置。

注意

其他 FTP 设置存储在 ApplicationHost.config 文件的 <system.ftpServer> 部分中,这些设置在 <location> 元素中进行指定。

兼容性

版本 说明
IIS 10.0 <ftpServer> 元素在 IIS 10.0 中未进行修改。
IIS 8.5 <ftpServer> 元素在 IIS 8.5 中未进行修改。
IIS 8.0 <ftpServer> 元素在 IIS 8.0 中未进行修改。
IIS 7.5 <ftpServer> 元素作为 IIS 7.5 的功能提供。
IIS 7.0 <ftpServer> 元素是在 IIS 7.0 的独立下载项 FTP 7.0 中引入的。
IIS 6.0 <ftpServer> 元素及其子元素替换位于 LM/MSFTPSVC 元数据库路径中的 IIS 6.0 FTP 设置。

注意

FTP 7.0 和 FTP 7.5 服务是 IIS 7.0 带外提供的,需要从以下 URL 下载和安装模块:

https://www.iis.net/expand/FTP

在 Windows 7 和 Windows Server 2008 R2 中,FTP 7.5 服务作为 IIS 7.5 的功能提供,因此无需再下载 FTP 服务。

安装

若要支持 Web 服务器的 FTP 发布,必须安装 FTP 服务。 为此,请按照以下步骤操作。

Windows Server 2012 或 Windows Server 2012 R2

  1. 在任务栏上,单击 “服务器管理器”。

  2. 在“服务器管理器”中,单击“管理”菜单,然后单击“添加角色和功能”

  3. 在“添加角色和功能”向导中,单击“下一步”。 选择安装类型,然后单击“下一步”。 选择目标服务器,然后单击“下一步”

  4. 在“服务器角色”页上,展开“Web 服务器(IIS)”,然后选择“FTP 服务器”

    注意

    若要支持 FTP 服务使用 ASP.Membership 身份验证或 IIS 管理器身份验证,除选择“FTP 服务”外还需选择“FTP 扩展性”
    Screenshot of F T P Service and F T P Extensibility selected in a Windows Server 2012 interface. .

  5. 单击“下一步”,然后在“选择功能”页上,再次单击“下一步”。

  6. “确认安装选择”页上,单击“安装”

  7. 在“结果” 页面中单击“关闭”

Windows 8 或 Windows 8.1

  1. 在“开始”屏幕上,将指针一直移动到左下角,右键单击“开始”按钮,然后单击“控制面板”

  2. 在“控制面板”中,单击“程序与功能”,然后单击“打开或关闭 Windows 功能”

  3. 展开“Internet Information Services”,然后选择“FTP 服务器”

    注意

    若要支持 FTP 服务使用 ASP.Membership 身份验证或 IIS 管理器身份验证,还需选择“FTP 扩展性”
    Screenshot of F T P Service and F T P Extensibility selected in a Windows 8 interface.

  4. 单击“确定”。

  5. 单击“关闭” 。

Windows Server 2008 R2

  1. 在任务栏上,单击“开始”,指向“管理工具”,然后单击“服务器管理器”

  2. 在“服务器管理器”层次结构窗格中,展开“角色”,然后单击“Web 服务器(IIS)”

  3. 在“Web 服务器(IIS)”窗格中,滚动到“角色服务”部分,然后单击“添加角色服务”

  4. 在“添加角色服务向导”的“选择角色服务”页,展开“FTP 服务器”

  5. 选择“FTP 服务”

    注意

    若要支持 FTP 服务使用 ASP.Membership 身份验证或 IIS 管理器身份验证,还需选择“FTP 扩展性”
    Screenshot of F T P Service and F T P Extensibility selected in a Windows Server 2008 interface.

  6. 单击 “下一步”

  7. “确认安装选择”页中,单击“安装”

  8. 在“结果” 页面中单击“关闭”

Windows 7

  1. 在任务栏上,单击“开始”,然后单击“控制面板”

  2. 在“控制面板”中,单击“程序与功能”,然后单击“打开或关闭 Windows 功能”

  3. 展开“Internet Information Services”,然后展开“FTP 服务器”

  4. 选择“FTP 服务”

    注意

    若要支持 FTP 服务使用 ASP.Membership 身份验证或 IIS 管理器身份验证,还需选择“FTP 扩展性”
    Screenshot of F T P Service and F T P Extensibility selected in a Windows 7 interface.

  5. 单击“确定”。

Windows Server 2008 或 Windows Vista

  1. 从以下 URL 下载安装包:

  2. 按照以下演练中的说明安装 FTP 服务:

操作方式

如何启用或禁用默认的 FTP 匿名身份验证设置

  1. 打开“Internet Information Services (IIS)管理器”:

    • 如果使用的是 Windows Server 2012 或 Windows Server 2012 R2:

      • 在任务栏上,单击“服务器管理器”,单击“工具”,然后单击“Internet Information Services (IIS)管理器”
    • 如果使用的是 Windows 8 或 Windows 8.1:

      • 按住 Windows 徽标键,按字母 X,然后单击“控制面板”
      • 单击“管理工具”,然后双击“Internet Information Services (IIS)管理器”
    • 如果使用的是 Windows Server 2008 或 Windows Server 2008 R2:

      • 在任务栏上,单击“开始”,指向“管理工具”,然后单击“Internet Information Services (IIS)管理器”
    • 如果使用的是 Windows Vista 或 Windows 7:

      • 在任务栏上,单击“开始”,然后单击“控制面板”
      • 双击“管理工具”,然后双击“Internet Information Services (IIS)管理器”
  2. 在“连接”窗格中,单击服务器名称

  3. 在服务器的“主页”窗格中,双击“FTP 身份验证”功能

  4. 在“FTP 身份验证”页上,选择“匿名身份验证”
    Screenshot of Anonymous Authentication selected in the F T P Authentication pane.

  5. 在“操作”窗格中,单击“启用”以启用匿名身份验证,或单击“禁用”以禁用匿名身份验证


如何启用或禁用默认的 FTP 基本身份验证设置

  1. 打开“Internet Information Services (IIS)管理器”:

    • 如果使用的是 Windows Server 2012 或 Windows Server 2012 R2:

      • 在任务栏上,单击“服务器管理器”,单击“工具”,然后单击“Internet Information Services (IIS)管理器”
    • 如果使用的是 Windows 8 或 Windows 8.1:

      • 按住 Windows 徽标键,按字母 X,然后单击“控制面板”
      • 单击“管理工具”,然后双击“Internet Information Services (IIS)管理器”
    • 如果使用的是 Windows Server 2008 或 Windows Server 2008 R2:

      • 在任务栏上,单击“开始”,指向“管理工具”,然后单击“Internet Information Services (IIS)管理器”
    • 如果使用的是 Windows Vista 或 Windows 7:

      • 在任务栏上,单击“开始”,然后单击“控制面板”
      • 双击“管理工具”,然后双击“Internet Information Services (IIS)管理器”
  2. 在“连接”窗格中,单击服务器名称

  3. 在服务器的“主页”窗格中,双击“FTP 身份验证”功能

  4. 在“FTP 身份验证”页上,选择“基本身份验证”
    Screenshot of Basic Authentication in the F T P Authentication pane.

  5. 在“操作”窗格中,单击“启用”以启用基本身份验证,或单击“禁用”以禁用基本身份验证

配置

默认 <ftpServer> 元素在 <siteDefaults> 级别进行配置。

特性

属性 说明
allowUTF8 可选的 Boolean 属性。

如果启用 UTF8,则为 true;否则为 false

默认值为 true
serverAutoStart 可选的 Boolean 属性。

如果 IIS 在启动 FTP 服务时自动启动 FTP 站点,则为 true;否则为 false

默认值为 true

子元素

元素 说明
connections 可选元素。

指定 FTP 站点的默认连接特定设置。
security 可选元素。

指定 FTP 站点的默认安全相关设置。
customFeatures 可选元素。

指定使用 FTP 扩展性开发的自定义 FTP 提供程序的默认集合。
messages 可选元素。

指定 FTP 站点将向 FTP 客户端显示的默认连接相关消息。
fileHandling 可选元素。

指定 FTP 站点的默认文件处理设置。
firewallSupport 可选元素。

指定通过防火墙建立的 FTP 连接所需的 FTP 站点的默认设置。
userIsolation 可选元素。

指定 FTP 连接的默认主目录查找行为。 例如,可以基于用户的登录名限制其可访问的主目录。
directoryBrowse 可选元素。

指定 FTP 站点的默认目录列表选项。 这些设置会影响 FTP 服务向 FTP 客户端显示目录列表的方式。
logFile 可选元素。

指定 FTP 站点的默认日志记录选项。

配置示例

以下配置示例显示服务器的 <siteDefaults> 元素示例,其中定义了多个 FTP 站点默认值。

<siteDefaults>
   <logFile logFormat="W3C" directory="%SystemDrive%\inetpub\logs\LogFiles" />
   <traceFailedRequestsLogging enabled="true" directory="%SystemDrive%\inetpub\logs\FailedReqLogFiles" />
   <ftpServer serverAutoStart="true">
      <connections controlChannelTimeout="300" />
      <security>
         <commandFiltering>
            <add command="SYST" allowed="false" />
         </commandFiltering>
         <ssl serverCertHash="57686f6120447564652c2049495320526f636b73" controlChannelPolicy="SslAllow" dataChannelPolicy="SslAllow" />
         <sslClientCertificates clientCertificatePolicy="CertIgnore" />
         <authentication>
             <anonymousAuthentication enabled="false" />
             <basicAuthentication enabled="false" />
             <clientCertAuthentication enabled="false" />
             <customAuthentication>
                <providers>
                   <add name="FtpCustomAuthenticationModule" enabled="false" />
                </providers>
             </customAuthentication>
         </authentication>
      </security>
      <messages bannerMessage="Welcome!" allowLocalDetailedErrors="true" />
      <fileHandling keepPartialUploads="false" />
      <firewallSupport externalIp4Address="169.254.10.10" />
      <userIsolation mode="None" />
      <directoryBrowse showFlags="StyleUnix, DisplayAvailableBytes" />
      <logFile period="Daily" enabled="true" />
   </ftpServer>
</siteDefaults>

代码示例

以下代码示例演示了如何设置多个 FTP 站点默认值。

AppCmd.exe

REM Configure FTP sites to start automatically by default.
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.serverAutoStart:"True" /commit:apphost

REM Configure the default control channel time-out for 300 seconds.
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.connections.controlChannelTimeout:"300" /commit:apphost

REM Configure the default FTP security options.
appcmd.exe set config -section:system.applicationHost/sites /+"siteDefaults.ftpServer.security.commandFiltering.[command='SYST',allowed='False']" /commit:apphost
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.security.ssl.controlChannelPolicy:"SslAllow" /commit:apphost
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.security.ssl.dataChannelPolicy:"SslAllow" /commit:apphost
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.security.ssl.serverCertHash:"57686f6120447564652c2049495320526f636b73" /commit:apphost
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.security.authentication.anonymousAuthentication.enabled:"False" /commit:apphost
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.security.authentication.basicAuthentication.enabled:"False" /commit:apphost
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.security.authentication.clientCertAuthentication.enabled:"False" /commit:apphost
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.security.sslClientCertificates.clientCertificatePolicy:"CertIgnore" /commit:apphost
appcmd.exe set config -section:system.applicationHost/sites /+"siteDefaults.ftpServer.security.authentication.customAuthentication.providers.[name='FtpCustomAuthenticationModule',enabled='False']" /commit:apphost

REM Configure a custom default banner message and local detailed error messages.
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.messages.bannerMessage:"Welcome!" /siteDefaults.ftpServer.messages.allowLocalDetailedErrors:"True" /commit:apphost

REM Configure the FTP service to keep partially-uploaded files by default.
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.fileHandling.keepPartialUploads:"False" /commit:apphost

REM Configure the default external IP address of a firewall.
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.firewallSupport.externalIp4Address:"169.254.10.10" /commit:apphost

REM Specify no user isolation by default.
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.userIsolation.mode:"None" /commit:apphost

REM Configure UNIX-style directory listings by default and display the available drive space.
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.directoryBrowse.showFlags:"StyleUnix, DisplayAvailableBytes" /commit:apphost

REM Enable logging by default with daily log file rollover.
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.ftpServer.logFile.period:"Daily" /siteDefaults.ftpServer.logFile.enabled:"True" /commit:apphost

注意

使用 AppCmd.exe 配置这些设置时,必须确保将 commit 参数设置为 apphost。 这会将配置设置提交到 ApplicationHost.config 文件中的相应位置部分。

C#

using System;
using System.Text;
using Microsoft.Web.Administration;

internal static class Sample
{
   private static void Main()
   {
      using (ServerManager serverManager = new ServerManager())
      {
         Configuration config = serverManager.GetApplicationHostConfiguration();
         ConfigurationSection sitesSection = config.GetSection("system.applicationHost/sites");
         ConfigurationElement siteDefaultsElement = sitesSection.GetChildElement("siteDefaults");
         ConfigurationElement ftpServerElement = siteDefaultsElement.GetChildElement("ftpServer");

         // Configure FTP sites to start automatically by default.
         ftpServerElement["serverAutoStart"] = true;

         // Configure the default control channel time-out for 300 seconds.
         ConfigurationElement connectionsElement = ftpServerElement.GetChildElement("connections");
            connectionsElement["controlChannelTimeout"] = 300;

         // Configure the default FTP security options.
         ConfigurationElement securityElement = ftpServerElement.GetChildElement("security");
         ConfigurationElement commandFilteringElement = securityElement.GetChildElement("commandFiltering");
         ConfigurationElementCollection commandFilteringCollection = commandFilteringElement.GetCollection();
         ConfigurationElement addElement = commandFilteringCollection.CreateElement("add");
            addElement["command"] = @"SYST";
            addElement["allowed"] = false;
            commandFilteringCollection.Add(addElement);
         ConfigurationElement sslElement = securityElement.GetChildElement("ssl");
            sslElement["controlChannelPolicy"] = @"SslAllow";
            sslElement["dataChannelPolicy"] = @"SslAllow";
            sslElement["serverCertHash"] = "57686f6120447564652c2049495320526f636b73";
         ConfigurationElement authenticationElement = securityElement.GetChildElement("authentication");
         ConfigurationElement anonymousAuthenticationElement = authenticationElement.GetChildElement("anonymousAuthentication");
            anonymousAuthenticationElement["enabled"] = false;
         ConfigurationElement basicAuthenticationElement = authenticationElement.GetChildElement("basicAuthentication");
            basicAuthenticationElement["enabled"] = false;
         ConfigurationElement clientCertAuthenticationElement = authenticationElement.GetChildElement("clientCertAuthentication");
            clientCertAuthenticationElement["enabled"] = false;
         ConfigurationElement sslClientCertificatesElement = securityElement.GetChildElement("sslClientCertificates");
            sslClientCertificatesElement["clientCertificatePolicy"] = @"CertIgnore";
         ConfigurationElement customAuthenticationElement = authenticationElement.GetChildElement("customAuthentication");
         ConfigurationElementCollection providersCollection = customAuthenticationElement.GetCollection("providers");
         ConfigurationElement addElement1 = providersCollection.CreateElement("add");
            addElement1["name"] = @"FtpCustomAuthenticationModule";
            addElement1["enabled"] = false;
            providersCollection.Add(addElement1);

         // Configure a custom default banner message and local detailed error messages.
         ConfigurationElement messagesElement = ftpServerElement.GetChildElement("messages");
            messagesElement["bannerMessage"] = @"Welcome!";
            messagesElement["allowLocalDetailedErrors"] = true;

         // Configure the FTP service to keep partially-uploaded files by default.
         ConfigurationElement fileHandlingElement = ftpServerElement.GetChildElement("fileHandling");
           fileHandlingElement["keepPartialUploads"] = false;

         // Configure the default external IP address of a firewall.
         ConfigurationElement firewallSupportElement = ftpServerElement.GetChildElement("firewallSupport");
            firewallSupportElement["externalIp4Address"] = @"169.254.10.10";

         // Specify no user isolation by default.
         ConfigurationElement userIsolationElement = ftpServerElement.GetChildElement("userIsolation");
            userIsolationElement["mode"] = @"None";

         // Configure UNIX-style directory listings by default and display the available drive space.
         ConfigurationElement directoryBrowseElement = ftpServerElement.GetChildElement("directoryBrowse");
            directoryBrowseElement["showFlags"] = @"StyleUnix, DisplayAvailableBytes";

         // Enable logging by default with daily log file rollover.
         ConfigurationElement logFileElement = ftpServerElement.GetChildElement("logFile");
            logFileElement["period"] = @"Daily";
            logFileElement["enabled"] = true;

         serverManager.CommitChanges();
      }
   }
}

VB.NET

Imports System
Imports System.Text
Imports Microsoft.Web.Administration

Module Sample
   Sub Main()
      Dim serverManager As ServerManager = New ServerManager
      Dim config As Configuration = serverManager.GetApplicationHostConfiguration
      Dim sitesSection As ConfigurationSection = config.GetSection("system.applicationHost/sites")
      Dim siteDefaultsElement As ConfigurationElement = sitesSection.GetChildElement("siteDefaults")
      Dim ftpServerElement As ConfigurationElement = siteDefaultsElement.GetChildElement("ftpServer")

      ' Configure FTP sites to start automatically by default.
      ftpServerElement("serverAutoStart") = True

      ' Configure the default control channel time-out for 300 seconds.
      Dim connectionsElement As ConfigurationElement = ftpServerElement.GetChildElement("connections")
         connectionsElement("controlChannelTimeout") = 300

      ' Configure the default FTP security options.
      Dim securityElement As ConfigurationElement = ftpServerElement.GetChildElement("security")
      Dim commandFilteringElement As ConfigurationElement = securityElement.GetChildElement("commandFiltering")
      Dim commandFilteringCollection As ConfigurationElementCollection = commandFilteringElement.GetCollection
      Dim addElement As ConfigurationElement = commandFilteringCollection.CreateElement("add")
         addElement("command") = "SYST"
         addElement("allowed") = False
         commandFilteringCollection.Add(addElement)
      Dim sslElement As ConfigurationElement = securityElement.GetChildElement("ssl")
         sslElement("controlChannelPolicy") = "SslAllow"
         sslElement("dataChannelPolicy") = "SslAllow"
         sslElement("serverCertHash") = "57686f6120447564652c2049495320526f636b73"
      Dim authenticationElement As ConfigurationElement = securityElement.GetChildElement("authentication")
      Dim anonymousAuthenticationElement As ConfigurationElement = authenticationElement.GetChildElement("anonymousAuthentication")
         anonymousAuthenticationElement("enabled") = False
      Dim basicAuthenticationElement As ConfigurationElement = authenticationElement.GetChildElement("basicAuthentication")
         basicAuthenticationElement("enabled") = False
      Dim clientCertAuthenticationElement As ConfigurationElement = authenticationElement.GetChildElement("clientCertAuthentication")
         clientCertAuthenticationElement("enabled") = False
      Dim sslClientCertificatesElement As ConfigurationElement = securityElement.GetChildElement("sslClientCertificates")
         sslClientCertificatesElement("clientCertificatePolicy") = "CertIgnore"
      Dim customAuthenticationElement As ConfigurationElement = authenticationElement.GetChildElement("customAuthentication")
      Dim providersCollection As ConfigurationElementCollection = customAuthenticationElement.GetCollection("providers")
      Dim addElement1 As ConfigurationElement = providersCollection.CreateElement("add")
         addElement1("name") = "FtpCustomAuthenticationModule"
         addElement1("enabled") = False
         providersCollection.Add(addElement1)

      ' Configure a custom default banner message and local detailed error messages.
      Dim messagesElement As ConfigurationElement = ftpServerElement.GetChildElement("messages")
         messagesElement("bannerMessage") = "Welcome!"
         messagesElement("allowLocalDetailedErrors") = True

      ' Configure the FTP service to keep partially-uploaded files by default.
      Dim fileHandlingElement As ConfigurationElement = ftpServerElement.GetChildElement("fileHandling")
         fileHandlingElement("keepPartialUploads") = False

      ' Configure the default external IP address of a firewall.
      Dim firewallSupportElement As ConfigurationElement = ftpServerElement.GetChildElement("firewallSupport")
         firewallSupportElement("externalIp4Address") = "169.254.10.10"

      ' Specify no user isolation by default.
      Dim userIsolationElement As ConfigurationElement = ftpServerElement.GetChildElement("userIsolation")
         userIsolationElement("mode") = "None"

      ' Configure UNIX-style directory listings by default and display the available drive space.
      Dim directoryBrowseElement As ConfigurationElement = ftpServerElement.GetChildElement("directoryBrowse")
         directoryBrowseElement("showFlags") = "StyleUnix, DisplayAvailableBytes"

      ' Enable logging by default with daily log file rollover.
      Dim logFileElement As ConfigurationElement = ftpServerElement.GetChildElement("logFile")
         logFileElement("period") = "Daily"
         logFileElement("enabled") = True

      serverManager.CommitChanges()
   End Sub

End Module

JavaScript

var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";

var sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST");
var siteDefaultsElement = sitesSection.ChildElements.Item("siteDefaults");
var ftpServerElement = siteDefaultsElement.ChildElements.Item("ftpServer");

// Configure FTP sites to start automatically by default.
ftpServerElement.Properties.Item("serverAutoStart").Value = true;

// Configure the default control channel time-out for 300 seconds.
var connectionsElement = ftpServerElement.ChildElements.Item("connections");
   connectionsElement.Properties.Item("controlChannelTimeout").Value = 300;

// Configure the default FTP security options.
var securityElement = ftpServerElement.ChildElements.Item("security");
var commandFilteringElement = securityElement.ChildElements.Item("commandFiltering");
var commandFilteringCollection = commandFilteringElement.Collection;
var addElement = commandFilteringCollection.CreateNewElement("add");
   addElement.Properties.Item("command").Value = "SYST";
   addElement.Properties.Item("allowed").Value = false;
   commandFilteringCollection.AddElement(addElement);
var sslElement = securityElement.ChildElements.Item("ssl");
   sslElement.Properties.Item("controlChannelPolicy").Value = "SslAllow";
   sslElement.Properties.Item("dataChannelPolicy").Value = "SslAllow";
   sslElement.Properties.Item("serverCertHash").Value = "57686f6120447564652c2049495320526f636b73";
var authenticationElement = securityElement.ChildElements.Item("authentication");
var anonymousAuthenticationElement = authenticationElement.ChildElements.Item("anonymousAuthentication");
   anonymousAuthenticationElement.Properties.Item("enabled").Value = false;
var basicAuthenticationElement = authenticationElement.ChildElements.Item("basicAuthentication");
   basicAuthenticationElement.Properties.Item("enabled").Value = false;
var clientCertAuthenticationElement = authenticationElement.ChildElements.Item("clientCertAuthentication");
   clientCertAuthenticationElement.Properties.Item("enabled").Value = false;
var sslClientCertificatesElement = securityElement.ChildElements.Item("sslClientCertificates");
    sslClientCertificatesElement.Properties.Item("clientCertificatePolicy").Value = "CertIgnore";
var customAuthenticationElement = authenticationElement.ChildElements.Item("customAuthentication");
var providersCollection = customAuthenticationElement.ChildElements.Item("providers").Collection;
var addElement1 = providersCollection.CreateNewElement("add");
   addElement1.Properties.Item("name").Value = "FtpCustomAuthenticationModule";
   addElement1.Properties.Item("enabled").Value = false;
   providersCollection.AddElement(addElement1);

// Configure a custom default banner message and local detailed error messages.
var messagesElement = ftpServerElement.ChildElements.Item("messages");
   messagesElement.Properties.Item("bannerMessage").Value = "Welcome!";
   messagesElement.Properties.Item("allowLocalDetailedErrors").Value = true;

// Configure the FTP service to keep partially-uploaded files by default.
var fileHandlingElement = ftpServerElement.ChildElements.Item("fileHandling");
   fileHandlingElement.Properties.Item("keepPartialUploads").Value = false;

// Configure the default external IP address of a firewall.
var firewallSupportElement = ftpServerElement.ChildElements.Item("firewallSupport");
   firewallSupportElement.Properties.Item("externalIp4Address").Value = "169.254.10.10";

// Specify no user isolation by default.
var userIsolationElement = ftpServerElement.ChildElements.Item("userIsolation");
   userIsolationElement.Properties.Item("mode").Value = "None";

// Configure UNIX-style directory listings by default and display the available drive space.
var directoryBrowseElement = ftpServerElement.ChildElements.Item("directoryBrowse");
   directoryBrowseElement.Properties.Item("showFlags").Value = "StyleUnix, DisplayAvailableBytes";

// Enable logging by default with daily log file rollover.
var logFileElement = ftpServerElement.ChildElements.Item("logFile");
   logFileElement.Properties.Item("period").Value = "Daily";
   logFileElement.Properties.Item("enabled").Value = true;

adminManager.CommitChanges();

VBScript

Set adminManager = createObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST")
Set siteDefaultsElement = sitesSection.ChildElements.Item("siteDefaults")
Set ftpServerElement = siteDefaultsElement.ChildElements.Item("ftpServer")

' Configure FTP sites to start automatically by default.
ftpServerElement.Properties.Item("serverAutoStart").Value = True

' Configure the default control channel time-out for 300 seconds.
Set connectionsElement = ftpServerElement.ChildElements.Item("connections")
   connectionsElement.Properties.Item("controlChannelTimeout").Value = 300

' Configure the default FTP security options.
Set securityElement = ftpServerElement.ChildElements.Item("security")
Set commandFilteringElement = securityElement.ChildElements.Item("commandFiltering")
Set commandFilteringCollection = commandFilteringElement.Collection
Set addElement = commandFilteringCollection.CreateNewElement("add")
   addElement.Properties.Item("command").Value = "SYST"
   addElement.Properties.Item("allowed").Value = False
   commandFilteringCollection.AddElement(addElement)
Set sslElement = securityElement.ChildElements.Item("ssl")
   sslElement.Properties.Item("controlChannelPolicy").Value = "SslAllow"
   sslElement.Properties.Item("dataChannelPolicy").Value = "SslAllow"
   sslElement.Properties.Item("serverCertHash").Value = "57686f6120447564652c2049495320526f636b73"
Set authenticationElement = securityElement.ChildElements.Item("authentication")
Set anonymousAuthenticationElement = authenticationElement.ChildElements.Item("anonymousAuthentication")
   anonymousAuthenticationElement.Properties.Item("enabled").Value = False
Set basicAuthenticationElement = authenticationElement.ChildElements.Item("basicAuthentication")
   basicAuthenticationElement.Properties.Item("enabled").Value = False
Set clientCertAuthenticationElement = authenticationElement.ChildElements.Item("clientCertAuthentication")
   clientCertAuthenticationElement.Properties.Item("enabled").Value = False
Set sslClientCertificatesElement = securityElement.ChildElements.Item("sslClientCertificates")
   sslClientCertificatesElement.Properties.Item("clientCertificatePolicy").Value = "CertIgnore"
Set customAuthenticationElement = authenticationElement.ChildElements.Item("customAuthentication")
Set providersCollection = customAuthenticationElement.ChildElements.Item("providers").Collection
Set addElement1 = providersCollection.CreateNewElement("add")
   addElement1.Properties.Item("name").Value = "FtpCustomAuthenticationModule"
   addElement1.Properties.Item("enabled").Value = False
   providersCollection.AddElement(addElement1)

' Configure a custom default banner message and local detailed error messages.
Set messagesElement = ftpServerElement.ChildElements.Item("messages")
   messagesElement.Properties.Item("bannerMessage").Value = "Welcome!"
   messagesElement.Properties.Item("allowLocalDetailedErrors").Value = True

' Configure the FTP service to keep partially-uploaded files by default.
Set fileHandlingElement = ftpServerElement.ChildElements.Item("fileHandling")
   fileHandlingElement.Properties.Item("keepPartialUploads").Value = False

' Configure the default external IP address of a firewall.
Set firewallSupportElement = ftpServerElement.ChildElements.Item("firewallSupport")
   firewallSupportElement.Properties.Item("externalIp4Address").Value = "169.254.10.10"

' Specify no user isolation by default.
Set userIsolationElement = ftpServerElement.ChildElements.Item("userIsolation")
   userIsolationElement.Properties.Item("mode").Value = "None"

' Configure UNIX-style directory listings by default and display the available drive space.
Set directoryBrowseElement = ftpServerElement.ChildElements.Item("directoryBrowse")
   directoryBrowseElement.Properties.Item("showFlags").Value = "StyleUnix, DisplayAvailableBytes"

' Enable logging by default with daily log file rollover.
Set logFileElement = ftpServerElement.ChildElements.Item("logFile")
   logFileElement.Properties.Item("period").Value = "Daily"
   logFileElement.Properties.Item("enabled").Value = True

adminManager.CommitChanges()