Export (0) Print
Expand All

Importing IIS Configurations Using Iiscnfg.vbs

Updated: August 22, 2005

Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1

You can use the command-line script iiscnfg.vbs, which is stored in systemroot\System32, to add configuration settings from an Extensible Markup Language (XML) metabase export file to the metabase of an IIS server.

The computer issuing the command must be running Microsoft Windows XP or a member of the Windows Server 2003 family. The computer that the command affects must be running a member of the Windows Server 2003 family with IIS 6.0.

ImportantImportant
You must be a member of the Administrators group on the local computer to run scripts and executables. As a security best practice, log on to your computer by 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. At a command prompt, type runas /profile /User:MyComputer\Administrator cmd to open a command window with administrator rights and then type cscript.exe ScriptName (include the script's full path and any parameters).

This topic includes the following information:

  • 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 that are 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 Backing Up IIS Configurations Using Iisback.vbs or the Importing IIS Configurations Using Iiscnfg.vbs/copy operation, 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 they aren't reflected in the MetaBase.xml file until the file is updated (every five minutes or every 50 changes). Use iiscnfg /save to review your changes immediately.

Syntax

iiscnfg /import /f [Path\]FileName.xml /sp SourcePath /dp DestiniationPath[ /d EncryptingPassword] [ /inherited ] [ /children ] [ /merge ][ /s Computer [ /u [Domain\]User [ /p Password]]]

Parameters

/f [Path\]FileName. xml

Required. Specifies the path and file name of the XML source file.

/sp SourcePath

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.

/dp DestinationPath

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

noteNote
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.

/d EncryptingPassword

Required only when the configuration file is encrypted. Specifies the password that was used to encrypt the configuration data.

/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.

/s Computer

Runs the script on the specified remote computer. Type the computer name or IP address without backslashes. The default is the local computer.

/u [Domain\]User

Runs the script with the permissions of the specified user account. This account must be a member of the Administrators group on the remote computer. By default, the script runs with the permissions of the current user of the local computer.

/p Password

Specifies the password of the user account that is specified in the /u parameter. If you omit this parameter, the script prompts you for the password and obscures the text you type.

Examples

Example 1:

The following command imports the NewSite Web site configuration from C:\Config.xml file to the metabase. The command uses the /f parameter to specify the name and location of the source file. Next, it uses the /sp parameter to indicate that the configuration is in the /lm/w3svc/5/Root/NewSite path in the Config.xml file. Finally, 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 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:

The following two-step example imports a custom logging configuration from C:\IISLogging.xml to 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 first command copies the IIsLogging.xml file to the remote server, Svr126.

copy IIsLogging.xml \\Svr126\c$

The second command imports IIsLogging.xml to 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.) Next, it uses the /children parameter to import all of the subkeys of the Logging key. Finally, 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 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:

This example demonstrates how the /merge parameter works by comparing a standard import operation with an import operation that uses the /merge parameter. Both of the 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 to 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 it 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 to the metabase. The /merge parameter directs IIS to add new properties from the import file to the metabase, to leave the 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. This 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 that are 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>

Related Information

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft