Iiscnfg.vbs: IIS configuration script
Updated: January 21, 2005
To view the command syntax, click a command:
iiscnfg /export
Syntax
Parameters
Remarks
- To perform this procedure, you must be a member of the Administrators group on the local computer, or you must have been delegated the appropriate authority. If the computer is joined to a domain, members of the Domain Admins group might be able to perform this procedure. As a security best practice, consider using Run as to perform this procedure.
- Use quotation marks to enclose metabase path elements that include spaces. Enclose only the element with spaces, not the entire path. For example, type "Default FTP Site"/IISAdmin, not "Default FTP Site/IISAdmin".
Examples
To export a Web site configuration
iiscnfg /export /f c:\finance\finance.xml /sp /lm/w3svc/2 /children /inherited
In response, Iiscnfg.vbs displays the following success message:
Configuration exported from /lm/w3svc/2 to file c:\finance\finance.xml
The resulting file includes all the keys and subkeys within the /lm/w3svc/2 path. It also includes an IisInheritedProperties key that contains the values of all inherited properties.
To export the entire IIS configuration of the local computer
iiscnfg /export /f d:\iistest\config.xml /sp / /children /d p@sswoRd61
In response, Iiscnfg.vbs displays the following success message:
Path / has been exported to d:\iistest\config.xml
Note that even a complete export of the configuration is not identical to the Metabase.xml file for the system. The session key, access control lists (ACLs), and passwords differ.
Also, you cannot tell by looking at the export file that it is encrypted. However, if you compare an encrypted and unencrypted version of the same file, you can see that the values of secure properties are changed in the encrypted version. Therefore, the file cannot be used in an import command without the password.
iiscnfg /import
Syntax
Parameters
Remarks
- To perform this procedure, you must be a member of the Administrators group on the local computer, or you must have been delegated the appropriate authority. If the computer is joined to a domain, members of the Domain Admins group might be able to perform this procedure. As a security best practice, consider using Run as to perform this procedure.
- Use quotation marks to enclose metabase path elements that include spaces. Enclose only the element with spaces, not the entire path. For example, type "Default FTP Site"/IISAdmin, not "Default FTP Site/IISAdmin".
- The imported key must be the type expected in its new position in the metabase path. If the key is not 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.
- Changes made by using Iiscnfg.vbs are effective immediately. These changes are reflected in the MetaBase.xml file when the file is updated (every five minutes or every 50 changes).
Examples
To import a Web site from an export file
The command uses the /f parameter to specify the name and location of the source file. It uses the /sp (source path) parameter to indicate the location in the Config.xml file of the keys that you want to import. In this case, the NewSite configuration is located in the /lm/w3svc/5 path in the Config.xml file. Then, it uses the /dp (destination path) parameter to specify the metabase location where the imported keys should be placed. In this case, the NewSite configuration keys should be imported into the /lm/w3svc/3 location in the metabase. Finally, it uses the /children parameter to include the child keys of the /lm/w3svc/5 in the import operation. Without the /children parameter, only the Web site root would be imported.
Remember that the /import operation overwrites without warning. If the metabase already has keys in the /lm/w3svc/3 position, those keys will be replaced by the imported keys.
iiscnfg.vbs /import /f c:\config.xml /sp /lm/w3svc/5/Root/NewSite /dp /lm/w3svc/3 /children
In response, Iiscnfg.vbs displays the following success message:
Configuration imported from /lm/w3svc/5 in c:\config.xml to /lm/w3svc/3 in the Metabase.
As a result of this command, the NewSite configuration now appears in IIS as the third Web site, with metabase path /lm/W3SVC/3.
To import a logging configuration into a remote computer
The procedure to import a logging configuration to a remote computer has two steps:
- Copy the source file to the remote computer. (Iiscnfg.vbs does not permit remote paths in the /f parameter.)
- 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.
To merge a virtual directory with a Web site
Both commands update the properties of the Investments virtual directory of a eb 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 was taken from a backup copy of the metabase created by using Iisback.vbs: IIS backup management script ).
Metabase before import
<IIsWebVirtualDirLocation ="/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.)
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
<IIsWebVirtualDirLocation ="/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.
<IIsWebVirtualDirLocation ="/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>
iiscnfg /copy
Syntax
Parameters
Remarks
- To perform this procedure, you must be a member of the Administrators group on the local computer, or you must have been delegated the appropriate authority. If the computer is joined to a domain, members of the Domain Admins group might be able to perform this procedure. As a security best practice, consider using Run as to perform this procedure.
- By default, IISCnfg copies the metabase of the local computer to the target computer specified by the /ts parameter. However, you can use the /s parameter to copy the metabase of another computer to the target computer.
- The copy operation uses Iisback.vbs: IIS backup management script to make a backup copy of the source metabase and the schema. Then, it copies the backup copy files (.MDX and .SCX) to the target computer and uses Iisback.vbs: IIS backup management script to replace the metabase and schema of the target computer with the backup copy. Although you can do these operations manually, the IISCnfg copy operation provides a convenient, one-step method to replicate an IIS configuration.
- The copy operation does not copy server content associated with the IIS configuration, such as Web pages and FTP files.
- The copy operation changes the computer-specific and system-specific properties in the metabase so that they are valid on the target computer. However, it does not adjust the directory or file paths. As a result, paths in the configuration might not be valid on the target computer.
Examples
To copy the IIS configuration of the local computer
iiscnfg /copy /ts SVR01 /tu SVR01\Admin06 /tp P@ssWord6
In response, Iiscnfg.vbs displays the following success message.
Backing up server 127.0.0.1 Backup complete.
The IP address, 127.0.0.1, is the loopback address and refers generically to the local computer. This address is used only when copying the configuration of the local computer.
To copy the IIS configuration of a remote computer
Unlike the /p parameter, which is optional, the /tp parameter is required. If you omit it, the command fails.
iiscnfg /copy /s SRV06 /u Domain01\Admin01 /ts MAINBKP /tu MAINBKP\Admin01 /tp P@ssWord6
In response, Iiscnfg.vbs prompts for the password of the account specified by the /u parameter. (It does not echo the password characters typed.) Then, after confirming the password, it copies the configuration and displays a message indicating that the copy operation was successful.
Enter the Password: Processing... Backing up server SRV06 Backup complete.
iiscnfg /save
Syntax
Parameters
Remarks
- To perform this procedure, you must be a member of the Administrators group on the local computer, or you must have been delegated the appropriate authority. If the computer is joined to a domain, members of the Domain Admins group might be able to perform this procedure. As a security best practice, consider using Run as to perform this procedure.
- Any changes made to the metabase, using scripts or IIS Manager, are written to memory first first and to disk at the next scheduled update, which may be several minutes later. As a result, an administrator may make metabase changes and then open metabase.xml only to find the changes aren't reflected. The /save command in iiscnfg.vbs resolves the problem by saving changes to the disk immediately.
Examples
To save the IIS configuration of the local computer
iiscnfg /save
In response, Iiscnfg.vbs displays the following success message.
Configuration saved.
To save the IIS configuration of a remote computer
iiscnfg /save /s SourceServer /u Administrator /p Kj30W
In response, iiscnfg.vbs displays the following message.
Configuration saved
Remarks
- IISCnfg.vbs imports and exports all or part of the configuration information that IIS stores in the metabase of an IIS server. The /copy operation copies both the entire metabase and the schema of the IIS server to the destination computer. The /save operation copies both the entire metabase and the schema of the IIS server to disk on the destination computer.
- Iisback.vbs: IIS backup management script , the IIS Backup Management Script, also saves and restores an IIS configuration. However, Iisback.vbs backs up the entire metabase and the schema. You cannot use it to save or restore selected elements of a configuration.
- The IISCnfg copy operation (/copy) replaces the functionality of IISSync.vbs and IISRepl.vbs, tools formerly included in Windows.
- Iiscnfg Requirements
- The computer issuing the command must be running Windows XP or a Windows Server 2003 operating system. The user must be a member of the Administrators group on any computer that the command affects.
- The computer that the command affects must be running Windows Server 2003 with Internet Information Services (IIS) 6.0.
- The metabase of an IIS server includes system-specific and computer-specific properties. Do not import the configuration of one IIS server to another IIS server without modification. Instead, use Iisback.vbs: IIS backup management script or the IISCnfg copy operation (/copy), which replace system-specific and computer-specific properties so that the configuration is valid on the target computer. For information about importing and exporting an IIS metabase, search for Metabase Import/Export in IIS 6.0 Help.
- Iiscfng.vbs displays a "Connecting to server" message while it connects to the IIS service on the specified computer. This message appears whenever you use Iiscnfg.vbs, whether on a local or remote computer.
- Iiscnfg.vbs provides an option to include inherited
properties in the export file. If you select this option,
Iiscnfg.vbs adds the inherited properties of the exported keys
to an IIsInheritedProperties key in the export file. When you
import keys from this file, you can elect to import the
inherited properties with the keys.
When inherited properties are imported, the imported keys retain the properties they inherited in the exporting configuration. If inherited properties are not imported, the keys inherit the properties of the importing configuration.
- To prevent unauthorized use of export files, IISCnfg.vbs
lets you encrypt the export file with a password. The password
encrypts the session key which, in turn, encrypts all properties
for which the secure attribute is set.
You can read an encrypted export file (only the session key and secure properties are encrypted) and you can delete the file. However, you cannot use the export file in a /import operation unless you provide the encrypting password. Also, you cannot remove the password encryption from an export file nor change the encrypting password.
If you do not use password encryption, the session key and secure properties are encrypted with a blank password, which prevents you from reading them, but allows any member of the Administrators group to import the metabase from the export file. Neither IIS 5.1 nor 6.0. support machine key encryption of export files.
Formatting legend
Format | Meaning |
Italic | Information that the user must supply |
Bold | Elements that the user must type exactly as shown |
Ellipsis (...) | Parameter that can be repeated several times in a command line |
Between brackets ([]) | Optional items |
Between braces ({}); choices separated by pipe (|). Example: {even|odd} | Set of choices from which the user must choose only one |
Courier font | Code or program output |