Share via


Importing IIS Configurations

You can use the command-line script iiscnfg.vbs, stored in the systemroot\System32\ directory, to add configuration settings from an XML metabase export file to the metabase of an IIS server.

The computer issuing the command must be running Windows XP or a Windows.NET Server family system. The computer that the command affects must be running Windows.NET with IIS.

important Important You must be a member of the Administrators group on the local computer to run scripts and executables, or you must have been delegated the appropriate authority. As a security best practice, log on to your computer using an account that is not in the Administrators group, and then use the Runas command to run your script or executable as an administrator. From the command prompt, type runas /user:administrative_accountname "script or executable command".

This topic includes the following sections:

  • Overview: Key concepts in understanding the copy procedures.
  • Syntax: The order in which you type a command and any arguments and options that follow it.
  • Parameters: The values given to variables in the command.
  • Examples: Sample code and an explanation of the results.

Overview

The metabase of an IIS server includes system-specific and computer-specific properties. Do not export the configuration of one IIS server to another IIS server without modification. Instead, use iisback.vbs or the iiscnfg.vbs copy operation (/copy), which replaces system-specific and computer-specific properties so that the configuration is valid on the destination computer.

Changes made by using iiscnfg.vbs are effective immediately, but aren't reflected in the MetaBase.xml file until the file is updated (every five minutes or every 50 changes). Use aa670325(v=vs.71).mdiiscnfg /save to review changes immediately.

Syntax

iiscnfg /import /f [Path\]FileName.xml**/sp** SourcePath**/dp** DestiniationPath[/dEncryptingPassword] [/inherited] [/children] [/merge][/sComputer [/u [Domain\]User [/pPassword]]]

Parameters

  • /f[Path\]FileName.xml
    Required. Specifies the path and file name of the XML source file.

  • /spSourcePath
    Required. Specifies the location in the XML file of the keys being imported. Enter the metabase path as it appears in the XML file. To import all of the keys in the source file, enter the metabase path of the root key.

  • /dpDestinationPath
    Required. Specifies the metabase path into which the keys are placed. Enter the metabase path as it appears in the XML file.

    The imported key must be of the type expected in its new position in the metabase path. If the key is not of the expected type, the configuration will not operate properly. For example, do not import the event logging configuration (/LM/Logging) to a Web site configuration path, such as /LM/W3SVC/3.

    If you specify a path that already exists in the metabase, the imported keys overwrite and replace the keys currently in that metabase path without warning.

  • /dEncryptingPassword
    Specifies the password that was used to encrypt the configuration data. This parameter is required when the configuration file is encrypted.

    If you do not provide the password for an encrypted file, or if you provide an incorrect password, the command fails.

  • /inherited
    Imports the inherited properties of the keys. This parameter is only effective when the source file includes inherited properties.

  • /children
    Recursively imports the subkeys of the specified key.

  • /merge
    Combines keys in the XML file with the existing metabase keys. Without this parameter, the keys in the XML file replace existing keys in the same metabase path.

    The /merge parameter adds keys to the metabase that appear only in the XML file, retains keys in the metabase that are not in the XML file, and applies the values in the XML file when a key appears in both the XML file and the metabase.

  • /sComputer
    Specifies the name or IP address of a remote computer (with no backslashes). The default is the local computer.

  • /u*[Domain\]User*
    Runs the script with the permissions of the specified user account. The default is the current user of the local computer.

  • /pPassword
    Specifies the password of the user account specified in the /u parameter. If you omit this parameter, IISCnfg prompts you for the password and obscures the text you type.

Example 1: Importing a Web Site Configuration from an Export File

The following command imports the NewSite Web site configuration from the C:\Config.xml file into the metabase.

The command uses the /f parameter to specify the name and location of the source file. It uses the /sp parameter to indicate that the configuration is in the /lm/w3svc/5/Root/NewSite path in the Config.xml file. Then, it uses the /dp parameter to specify that the keys in that path should be placed in the /lm/w3svc/1/Root/401KApp location in the metabase.

iiscnfg.vbs /import /f c:\config.xml /sp /lm/w3svc/5/Root/NewSite /dp /lm/w3svc/1/Root/401KApp

In response, iiscnfg.vbs displays the following success message:

Configuration imported from /lm/w3svc/5/Root/NewSite in c:\config.xml to /lm/w3svc/1/Root/401KApp in the Metabase.

As a result of this command, the NewSite configuration now appears in IIS as the first Web site, with metabase path W3SVC/1.

Example 2: Importing a Logging Configuration into a Remote Computer

The following example imports a custom logging configuration in C:\IISLogging.xml into the IIS metabase of a remote computer. You can use this method, or an extension of this method, to propagate a configuration to a group of servers.

The procedure to import a logging configuration to a remote computer has two steps:

  1. Copy the source file to the remote computer. (iiscnfg.vbs does not permit remote paths in the /f parameter.)
  2. Import the configuration to IIS.

The first command copies the Iislogging.xml file to the remote server, Svr126:

copy IISLogging.xml \\Svr126\c$

The second command imports iislogging.xml into the IIS configuration of Svr126. It uses the /f parameter to identify the source file, the /sp parameter to specify the /LM/Logging/Custom Logging metabase path to import, and the /dp parameter to place the imported keys in the same location in the target configuration, /LM/Logging/Custom Logging. (Use quotation marks to enclose path elements that include spaces.) It uses the /children parameter to import all subkeys of the Logging key.

To act on Svr126, it uses the /s parameter to specify the server, and the /u and /p parameters to run the script with the permissions of the user's administrator account on the remote computer.

iiscnfg /import /f C:\IISLogging.xml /sp "/lm/logging/custom logging" /dp "/lm/logging/custom logging" /children /s Svr126 /u Svr126\Administrator /p p@ssword1#

In response, iiscnfg.vbs displays the following success message:

Connecting to server ... Done.
Configuration imported from /lm/logging/custom logging in file C:\IISLogging.xml to
 /lm/logging/custom logging in the Metabase.

As a result, the /LM/Logging/Custom Logging key and its subkeys have been copied from the local metabase to the metabase of Svr126.

Example 3: Merging a Virtual Directory with a Web Site

This example demonstrates how the /merge parameter works by comparing a standard import operation with an import operation that uses the /merge parameter.

Both commands in this example update the properties of the Investments virtual directory of a Web site by using the same import file, Invest_vdir.xml.

The following sample shows the Investments metabase key before any import operations are run. (This sample is taken from a backup copy of the metabase created by using iisback.vbs).

Metabase before import

<IIsWebVirtualDir   Location ="/LM/W3SVC/1509060625/root/Investments"
    AccessFlags="AccessRead | AccessScript"
    AppFriendlyName="Investments"
    AppIsolated="2"
    AppRoot="/LM/W3SVC/1509060625/Root/Investments"
    DirBrowseFlags="DirBrowseShowDate | DirBrowseShowTime | DirBrowseShowSize | DirBrowseShowExtension | DirBrowseShowLongDate | EnableDefaultDoc"
    Path="E:\public\Download">
</IIsWebVirtualDir>

The following sample shows the content of the Invest_vdir.xml file that will be used in the import operations. (This sample was created by exporting the Investments metabase key and then editing the export file.)

Please note that the following properties of the Investments key are changed in the XML file:

  • The value of the AccessFlags property is changed.
  • The AuthFlags property is added.
  • The DirBrowseFlags property is omitted.

Import File Content

<IIsWebVirtualDir   Location ="/LM/W3SVC/1509060625/root/Investments"
AccessFlags="AccessRead"
AuthFlags="AuthAnonymous | AuthNTLM"
AppFriendlyName="Investments"
AppIsolated="2"
AppRoot="/LM/W3SVC/1509060625/Root/Investments"
Path="E:\public\Download"
>
</IIsWebVirtualDir>
Command 1: Standard Import

The following command imports the Invest_vdir.xml file into the metabase without using the /merge parameter. The command directs IIS to replace the Investments key in the metabase with the Investments key in the XML file.

The command uses the /f parameter to specify the import file and uses the same metabase path in the source path (/sp) and destination path (/dp) parameters.

iiscnfg /import /f e:\iistest\Invest_vdir.xml /sp /LM/W3SVC/1509060625/root/Investments /dp /LM/W3SVC/1509060625/root/Investments

As a result of this command, the Investments key in the metabase is now identical to the Investments key in the Invest_vdir.xml import file.

Command 2: Import and merge

The following command merges the Investments key in the Invest_vdir.xml file into the metabase. The /merge parameter directs IIS to add new properties from the import file to the metabase, to leave metabase properties that are not in the import file unchanged, and to apply the import file value when a property appears in both the import file and in the metabase.

The command is identical to Command 1, except that the /merge parameter is added.

iiscnfg /import /f e:\iistest\Invest_vdir.xml /sp /LM/W3SVC/1509060625/root/Investments /dp /LM/W3SVC/1509060625/root/Investments /merge

As a result of this command, the content of the Investments key in the metabase is a combination of its sources, as shown in the following sample.

Note that the following properties of the Investments key in the metabase are changed:

  • The value of the AccessFlags property, which appeared in the metabase and the XML file, is changed. The value in the XML file now appears in the metabase.
  • The AuthFlags property, which appeared only in the XML file, is added.
  • The DirBrowseFlags property, which appeared only in the metabase, is unchanged.
<IIsWebVirtualDir   Location ="/LM/W3SVC/1509060625/root/Investments"
        AccessFlags="AccessRead"
        AppFriendlyName="Investments"
        AppIsolated="2"
        AppRoot="/LM/W3SVC/1509060625/Root/Investments"
        AuthFlags="AuthAnonymous | AuthNTLM"
        DirBrowseFlags="DirBrowseShowDate | DirBrowseShowTime | DirBrowseShowSize | DirBrowseShowExtension | DirBrowseShowLongDate | EnableDefaultDoc"
        Path="E:\public\Download"
    >
</IIsWebVirtualDir>